|
|
<?php
namespace App\Models;
use App\Models\Traits\Validatable; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Str;
class File extends Model { use HasFactory, SoftDeletes;
protected $primaryKey = 'uuid';
protected $fillable = [ "uuid", "original_name", "ext", "mimetype", "width", "server_path", "height", "file_size", "sort", "alts", "description", "user_id", "ip", "collection_id", "published_at", ];
protected $casts = [ 'alts' => 'array', ];
protected function alts(): Attribute { return Attribute::make( set: fn ($value) => json_encode($value), ); }
// public function rules(): array
// {
// return [
// "image" => [
// "mimes:" . app()->collection->getExts(),
// "mimetypes:" . app()->collection->getMimeTypes(),
// "dimensions:min_width=" . app()->collection->min_width . ",min_height=" . app()->collection->min_height . ',max_width=' . app()->collection->max_width . ',max_height=' . app()->collection->max_height,
// "max:" . app()->collection->max_size,
// "min:" . app()->collection->min_size,
// ],
// ];
// }
}
|