- VehicleLog 모델 생성 - VehicleLogController (CRUD, 엑셀 다운로드) - 차량일지 라우트 추가 (/finance/vehicle-logs/*) - React 기반 UI (vehicle-logs.blade.php) - VehicleLogMenuSeeder (법인차량관리 > 차량일지 메뉴) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
87 lines
2.3 KiB
PHP
87 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class VehicleLog extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'vehicle_id',
|
|
'log_date',
|
|
'department',
|
|
'driver_name',
|
|
'trip_type',
|
|
'departure_type',
|
|
'departure_name',
|
|
'departure_address',
|
|
'arrival_type',
|
|
'arrival_name',
|
|
'arrival_address',
|
|
'distance_km',
|
|
'note',
|
|
];
|
|
|
|
protected $casts = [
|
|
'log_date' => 'date',
|
|
'distance_km' => 'integer',
|
|
];
|
|
|
|
// trip_type 상수
|
|
public const TRIP_TYPE_COMMUTE_TO = 'commute_to';
|
|
public const TRIP_TYPE_COMMUTE_FROM = 'commute_from';
|
|
public const TRIP_TYPE_BUSINESS = 'business';
|
|
public const TRIP_TYPE_PERSONAL = 'personal';
|
|
|
|
// location_type 상수
|
|
public const LOCATION_TYPE_HOME = 'home';
|
|
public const LOCATION_TYPE_OFFICE = 'office';
|
|
public const LOCATION_TYPE_CLIENT = 'client';
|
|
public const LOCATION_TYPE_OTHER = 'other';
|
|
|
|
public static function tripTypeLabels(): array
|
|
{
|
|
return [
|
|
self::TRIP_TYPE_COMMUTE_TO => '출근용',
|
|
self::TRIP_TYPE_COMMUTE_FROM => '퇴근용',
|
|
self::TRIP_TYPE_BUSINESS => '업무용',
|
|
self::TRIP_TYPE_PERSONAL => '비업무',
|
|
];
|
|
}
|
|
|
|
public static function locationTypeLabels(): array
|
|
{
|
|
return [
|
|
self::LOCATION_TYPE_HOME => '자택',
|
|
self::LOCATION_TYPE_OFFICE => '회사',
|
|
self::LOCATION_TYPE_CLIENT => '거래처',
|
|
self::LOCATION_TYPE_OTHER => '기타',
|
|
];
|
|
}
|
|
|
|
public function vehicle(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CorporateVehicle::class, 'vehicle_id');
|
|
}
|
|
|
|
public function getTripTypeLabelAttribute(): string
|
|
{
|
|
return self::tripTypeLabels()[$this->trip_type] ?? $this->trip_type;
|
|
}
|
|
|
|
public function getDepartureTypeLabelAttribute(): string
|
|
{
|
|
return self::locationTypeLabels()[$this->departure_type] ?? ($this->departure_type ?? '');
|
|
}
|
|
|
|
public function getArrivalTypeLabelAttribute(): string
|
|
{
|
|
return self::locationTypeLabels()[$this->arrival_type] ?? ($this->arrival_type ?? '');
|
|
}
|
|
}
|