|
|
<?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", "avalible_exts", "memetypes", "model", "expire_date", ];
protected $casts = [ 'exts' => 'array', 'avalible_exts' => 'array', 'memetypes' => 'array', ];
protected function exts(): Attribute { return Attribute::make( set: fn ($value) => json_encode($value), ); } protected function avalible_exts(): Attribute { return Attribute::make( set: fn ($value) => json_encode($value), ); } protected function memetypes(): 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); }
}
|