Add sort_order to slides table with migration and model fillable. Add destroyBulk() for batch soft-delete by type/service_id and reorder() for drag-and-drop slide ordering. Auto-assign sort_order on image and zip uploads.
40 lines
810 B
PHP
40 lines
810 B
PHP
<?php
|
|
|
|
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;
|
|
|
|
class Slide extends Model
|
|
{
|
|
use HasFactory;
|
|
use SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'type',
|
|
'service_id',
|
|
'original_filename',
|
|
'stored_filename',
|
|
'thumbnail_filename',
|
|
'expire_date',
|
|
'uploader_name',
|
|
'uploaded_at',
|
|
'sort_order',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'expire_date' => 'date',
|
|
'uploaded_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function service(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Service::class);
|
|
}
|
|
}
|