2026-02-03 11:24:11 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2026-02-03 11:24:11 +09:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2026-02-03 20:01:51 +09:00
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
2026-02-25 11:45:01 +09:00
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
2026-02-03 11:24:11 +09:00
|
|
|
|
|
|
|
|
class VehicleLog extends Model
|
|
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
use HasFactory, SoftDeletes;
|
2026-02-03 11:24:11 +09:00
|
|
|
|
|
|
|
|
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 = [
|
2026-02-03 20:01:51 +09:00
|
|
|
'log_date' => 'date',
|
2026-02-03 11:24:11 +09:00
|
|
|
'distance_km' => 'integer',
|
|
|
|
|
];
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
/**
|
|
|
|
|
* 차량 관계
|
|
|
|
|
*/
|
|
|
|
|
public function vehicle(): BelongsTo
|
2026-02-03 11:24:11 +09:00
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
return $this->belongsTo(CorporateVehicle::class, 'vehicle_id');
|
2026-02-03 11:24:11 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
/**
|
|
|
|
|
* 테넌트 관계
|
|
|
|
|
*/
|
|
|
|
|
public function tenant(): BelongsTo
|
2026-02-03 11:24:11 +09:00
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
return $this->belongsTo(Tenant::class);
|
2026-02-03 11:24:11 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
/**
|
|
|
|
|
* 구분(trip_type) 목록
|
|
|
|
|
*/
|
|
|
|
|
public static function getTripTypes(): array
|
2026-02-03 11:24:11 +09:00
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
return [
|
|
|
|
|
'commute_to' => '출근용',
|
|
|
|
|
'commute_from' => '퇴근용',
|
|
|
|
|
'business' => '업무용',
|
|
|
|
|
'personal' => '비업무',
|
|
|
|
|
];
|
2026-02-03 11:24:11 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
/**
|
|
|
|
|
* 분류(location_type) 목록
|
|
|
|
|
*/
|
|
|
|
|
public static function getLocationTypes(): array
|
2026-02-03 11:24:11 +09:00
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
return [
|
|
|
|
|
'home' => '자택',
|
|
|
|
|
'office' => '회사',
|
|
|
|
|
'client' => '거래처',
|
|
|
|
|
'other' => '기타',
|
|
|
|
|
];
|
2026-02-03 11:24:11 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-03 20:01:51 +09:00
|
|
|
/**
|
|
|
|
|
* 비고 목록
|
|
|
|
|
*/
|
|
|
|
|
public static function getNoteOptions(): array
|
2026-02-03 11:24:11 +09:00
|
|
|
{
|
2026-02-03 20:01:51 +09:00
|
|
|
return [
|
|
|
|
|
'거래처방문',
|
|
|
|
|
'제조시설등',
|
|
|
|
|
'회의참석',
|
|
|
|
|
'판촉활동',
|
|
|
|
|
'교육등',
|
|
|
|
|
];
|
2026-02-03 11:24:11 +09:00
|
|
|
}
|
|
|
|
|
}
|