582f454a5a
- 将后端目录名从大写改为小写 (Controller->controller 等) - 将命名空间从 App\ 改为 app\ (符合 webman 官方规范) - 移除不必要的 bootstrap 目录 - 完善出差审批业务功能: - 添加删除草稿功能 - 添加审批操作功能(同意/拒绝) - 完善审批详情页,显示审批人和审批记录 - 前端优化: - 调整列表页行高 - 隐藏底部导航栏 - 仪表盘只显示3个快捷入口 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
60 lines
1.3 KiB
PHP
60 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace app\model;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class BusinessTripItinerary extends Model
|
|
{
|
|
protected $table = 'business_trip_itinerary';
|
|
|
|
protected $fillable = [
|
|
'business_trip_id',
|
|
'start_time',
|
|
'end_time',
|
|
'departure',
|
|
'destination',
|
|
'transport',
|
|
'trip_type',
|
|
'remark',
|
|
];
|
|
|
|
protected $casts = [
|
|
'business_trip_id' => 'integer',
|
|
'start_time' => 'datetime',
|
|
'end_time' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 行程类型常量
|
|
*/
|
|
const TRIP_TYPE_ONEWAY = 'oneway'; // 单程
|
|
const TRIP_TYPE_ROUNDTRIP = 'roundtrip'; // 往返
|
|
|
|
/**
|
|
* 关联出差申请
|
|
*/
|
|
public function businessTrip()
|
|
{
|
|
return $this->belongsTo(BusinessTrip::class, 'business_trip_id');
|
|
}
|
|
|
|
/**
|
|
* 计算天数
|
|
*/
|
|
public function getDurationDays(): int
|
|
{
|
|
if (!$this->start_time || !$this->end_time) {
|
|
return 0;
|
|
}
|
|
$start = \DateTime::createFromFormat('Y-m-d H:i:s', $this->start_time);
|
|
$end = \DateTime::createFromFormat('Y-m-d H:i:s', $this->end_time);
|
|
if (!$start || !$end) {
|
|
return 0;
|
|
}
|
|
return $end->diff($start)->days + 1;
|
|
}
|
|
}
|