feat(vehicle): dedicated photo upload with MediaLibrary + form field
Vehicle model now implements HasMedia + InteractsWithMedia and
registers a 'photos' collection. VehicleResource form gets a
SpatieMediaLibraryFileUpload section (collapsible, max 6 photos,
imageEditor enabled).
Dashboard already checks vehicle->getFirstMediaUrl('photos') first
and falls back to the WO's photos, so uploading here immediately
populates the vehicle card on the dashboard without any view changes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -7,10 +7,12 @@ use App\Models\Concerns\Auditable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
|
||||
class Vehicle extends Model
|
||||
class Vehicle extends Model implements HasMedia
|
||||
{
|
||||
use Auditable, BelongsToTenant, SoftDeletes;
|
||||
use Auditable, BelongsToTenant, InteractsWithMedia, SoftDeletes;
|
||||
|
||||
public const BODY_TYPES = [
|
||||
'sedan' => 'Sedan', 'hatchback' => 'Hatchback', 'suv' => 'SUV',
|
||||
@@ -44,4 +46,9 @@ class Vehicle extends Model
|
||||
{
|
||||
return trim("{$this->make} {$this->model} " . ($this->year ?: ''));
|
||||
}
|
||||
|
||||
public function registerMediaCollections(): void
|
||||
{
|
||||
$this->addMediaCollection('photos');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user