Adding is folder field and helper method

parent 587300fd
...@@ -28,6 +28,7 @@ class File extends Model implements TaggableInterface ...@@ -28,6 +28,7 @@ class File extends Model implements TaggableInterface
protected $table = 'media__files'; protected $table = 'media__files';
public $translatedAttributes = ['description', 'alt_attribute', 'keywords']; public $translatedAttributes = ['description', 'alt_attribute', 'keywords'];
protected $fillable = [ protected $fillable = [
'is_folder',
'description', 'description',
'alt_attribute', 'alt_attribute',
'keywords', 'keywords',
...@@ -41,6 +42,7 @@ class File extends Model implements TaggableInterface ...@@ -41,6 +42,7 @@ class File extends Model implements TaggableInterface
'folder_id', 'folder_id',
]; ];
protected $appends = ['path_string', 'media_type']; protected $appends = ['path_string', 'media_type'];
protected $casts = ['is_folder' => 'boolean', ];
protected static $entityNamespace = 'asgardcms/media'; protected static $entityNamespace = 'asgardcms/media';
public function getPathAttribute($value) public function getPathAttribute($value)
...@@ -58,6 +60,11 @@ class File extends Model implements TaggableInterface ...@@ -58,6 +60,11 @@ class File extends Model implements TaggableInterface
return FileHelper::getTypeByMimetype($this->mimetype); return FileHelper::getTypeByMimetype($this->mimetype);
} }
public function isFolder() : bool
{
return $this->is_folder;
}
public function isImage() public function isImage()
{ {
return in_array(pathinfo($this->path, PATHINFO_EXTENSION), $this->imageExtensions); 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