You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
61 lines
1.5 KiB
<?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",
|
|
"model_id",
|
|
"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,
|
|
// ],
|
|
// ];
|
|
// }
|
|
}
|