feat:차량일지 기능 구현
- 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>
This commit is contained in:
@@ -2,13 +2,14 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class VehicleLog extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
use HasFactory, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
@@ -28,65 +29,63 @@ class VehicleLog extends Model
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'log_date' => 'date:Y-m-d',
|
||||
'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';
|
||||
public const TRIP_TYPE_COMMUTE_ROUND = 'commute_round';
|
||||
public const TRIP_TYPE_BUSINESS_ROUND = 'business_round';
|
||||
public const TRIP_TYPE_PERSONAL_ROUND = 'personal_round';
|
||||
|
||||
// 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 => '비업무용(개인)',
|
||||
self::TRIP_TYPE_COMMUTE_ROUND => '출퇴근용(왕복)',
|
||||
self::TRIP_TYPE_BUSINESS_ROUND => '업무용(왕복)',
|
||||
self::TRIP_TYPE_PERSONAL_ROUND => '비업무용(왕복)',
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
/**
|
||||
* 테넌트 관계
|
||||
*/
|
||||
public function tenant(): BelongsTo
|
||||
{
|
||||
return self::tripTypeLabels()[$this->trip_type] ?? $this->trip_type;
|
||||
return $this->belongsTo(Tenant::class);
|
||||
}
|
||||
|
||||
public function getDepartureTypeLabelAttribute(): string
|
||||
/**
|
||||
* 구분(trip_type) 목록
|
||||
*/
|
||||
public static function getTripTypes(): array
|
||||
{
|
||||
return self::locationTypeLabels()[$this->departure_type] ?? ($this->departure_type ?? '');
|
||||
return [
|
||||
'commute_to' => '출근용',
|
||||
'commute_from' => '퇴근용',
|
||||
'business' => '업무용',
|
||||
'personal' => '비업무',
|
||||
];
|
||||
}
|
||||
|
||||
public function getArrivalTypeLabelAttribute(): string
|
||||
/**
|
||||
* 분류(location_type) 목록
|
||||
*/
|
||||
public static function getLocationTypes(): array
|
||||
{
|
||||
return self::locationTypeLabels()[$this->arrival_type] ?? ($this->arrival_type ?? '');
|
||||
return [
|
||||
'home' => '자택',
|
||||
'office' => '회사',
|
||||
'client' => '거래처',
|
||||
'other' => '기타',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 비고 목록
|
||||
*/
|
||||
public static function getNoteOptions(): array
|
||||
{
|
||||
return [
|
||||
'거래처방문',
|
||||
'제조시설등',
|
||||
'회의참석',
|
||||
'판촉활동',
|
||||
'교육등',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user