- VehicleLogController: CRUD 및 통계 API 추가 - VehicleLog 모델: 구분/분류 코드 정의 추가 - vehicle-logs.blade.php: React 기반 운행기록부 UI - routes/web.php: vehicles, summary 엔드포인트 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
92 lines
1.9 KiB
PHP
92 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class VehicleLog extends Model
|
|
{
|
|
use HasFactory, 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',
|
|
];
|
|
|
|
/**
|
|
* 차량 관계
|
|
*/
|
|
public function vehicle(): BelongsTo
|
|
{
|
|
return $this->belongsTo(CorporateVehicle::class, 'vehicle_id');
|
|
}
|
|
|
|
/**
|
|
* 테넌트 관계
|
|
*/
|
|
public function tenant(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
/**
|
|
* 구분(trip_type) 목록
|
|
*/
|
|
public static function getTripTypes(): array
|
|
{
|
|
return [
|
|
'commute_to' => '출근용',
|
|
'commute_from' => '퇴근용',
|
|
'business' => '업무용',
|
|
'personal' => '비업무',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 분류(location_type) 목록
|
|
*/
|
|
public static function getLocationTypes(): array
|
|
{
|
|
return [
|
|
'home' => '자택',
|
|
'office' => '회사',
|
|
'client' => '거래처',
|
|
'other' => '기타',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 비고 목록
|
|
*/
|
|
public static function getNoteOptions(): array
|
|
{
|
|
return [
|
|
'거래처방문',
|
|
'제조시설등',
|
|
'회의참석',
|
|
'판촉활동',
|
|
'교육등',
|
|
];
|
|
}
|
|
}
|