- CorporateVehicle 모델 (photos 관계 포함) - VehiclePhotoService (R2 저장, 최대 10장 제한) - VehiclePhotoController (index/store/destroy) - StoreVehiclePhotoRequest (동적 max 검증) - finance.php 라우트 등록
41 lines
895 B
PHP
41 lines
895 B
PHP
<?php
|
|
|
|
namespace App\Models\Finance;
|
|
|
|
use App\Models\Commons\File;
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class CorporateVehicle extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $table = 'corporate_vehicles';
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'plate_number',
|
|
'model',
|
|
'vehicle_type',
|
|
'ownership_type',
|
|
'mileage',
|
|
'options',
|
|
'is_active',
|
|
];
|
|
|
|
protected $casts = [
|
|
'mileage' => 'integer',
|
|
'options' => 'array',
|
|
'is_active' => 'boolean',
|
|
];
|
|
|
|
public function photos(): HasMany
|
|
{
|
|
return $this->hasMany(File::class, 'document_id')
|
|
->where('document_type', 'corporate_vehicle')
|
|
->orderBy('id');
|
|
}
|
|
}
|