Adding is folder field and helper method

parent 587300fd
......@@ -28,6 +28,7 @@ class File extends Model implements TaggableInterface
protected $table = 'media__files';
public $translatedAttributes = ['description', 'alt_attribute', 'keywords'];
protected $fillable = [
'is_folder',
'description',
'alt_attribute',
'keywords',
......@@ -41,6 +42,7 @@ class File extends Model implements TaggableInterface
'folder_id',
];
protected $appends = ['path_string', 'media_type'];
protected $casts = ['is_folder' => 'boolean', ];
protected static $entityNamespace = 'asgardcms/media';
public function getPathAttribute($value)
......@@ -58,6 +60,11 @@ class File extends Model implements TaggableInterface
return FileHelper::getTypeByMimetype($this->mimetype);
}
public function isFolder() : bool
{
return $this->is_folder;
}
public function isImage()
{
return in_array(pathinfo($this->path, PATHINFO_EXTENSION), $this->imageExtensions);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment