|
|
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes;
class Collection extends Model { use HasFactory, SoftDeletes;
protected $fillable = [ "name", "path", "public", "disk", "count", "tmp_support", "remove_tmp_time", "max_file_size", "min_file_size", "max_width", "min_width", "max_height", "min_height", "alt_required", "description_required", "exts", "ext", "mimetypes", "model", "expire_date", ];
protected $casts = [ 'exts' => 'array', 'mimetypes' => 'array', ];
public function files() { return $this->hasMany(File::class); }
protected function exts(): Attribute { return Attribute::make( set: fn ($value) => json_encode($value), ); }
protected function mimetypes(): Attribute { return Attribute::make( set: fn ($value) => json_encode($value), ); }
public function getExts() { return implode(",", app()->collection->exts); }
public function getMimeTypes() { return implode(",", app()->collection->mimetypes); }
}
|