'basename']; public static $croppableTypes = [ 'image/jpeg', 'image/gif', 'image/png', 'image/webp' ]; /** * @var string The database table used by the model. */ public $table = 'responsive_source_files'; /** * @var array Guarded fields */ protected $guarded = ['*']; /** * @var array Fillable fields */ protected $fillable = ['id', 'basename', 'extension', 'tags', 'slug', 'aspect_ratio', 'min_width']; public $jsonable = ['tags', 'aspect_ratio']; /** * @var array Relations */ public $hasOne = []; public $hasMany = [ 'attachments' => [Attachment::class, 'key' => 'file_id'] ]; public $belongsTo = []; public $belongsToMany = []; public $morphTo = []; public $morphOne = []; public $morphMany = []; public $attachOne = []; public $attachMany = []; public function getPathAttribute() { return 'source/'.$this->slug.'.'.$this->extension; } public function getUrlAttribute() { return Storage::disk('uploads')->url($this->path); } public function getTypeAttribute() { return Storage::disk('uploads')->mimeType($this->path); } public function getSizeAttribute() { return Storage::disk('uploads')->size($this->path); } public function isCroppable(): bool { return in_array($this->type, static::$croppableTypes); } }