/home/techb158/immovalet.com/platform/core/media/src/Models
Edit: /home/techb158/immovalet.com/platform/core/media/src/Models/MediaFile.php (2594B)
'json',
];
protected static function boot()
{
parent::boot();
static::deleting(function (MediaFile $file) {
if ($file->isForceDeleting()) {
RvMedia::deleteFile($file);
}
});
}
/**
* @return BelongsTo
*/
public function folder(): BelongsTo
{
return $this->belongsTo(MediaFolder::class, 'id', 'folder_id');
}
/**
* @return string
*/
public function getTypeAttribute(): string
{
$type = 'document';
foreach (config('core.media.media.mime_types', []) as $key => $value) {
if (in_array($this->attributes['mime_type'], $value)) {
$type = $key;
break;
}
}
return $type;
}
/**
* @return string
*/
public function getHumanSizeAttribute(): string
{
return human_file_size($this->attributes['size']);
}
/**
* @return string
*/
public function getIconAttribute(): string
{
switch ($this->type) {
case 'image':
$icon = 'far fa-file-image';
break;
case 'video':
$icon = 'far fa-file-video';
break;
case 'pdf':
$icon = 'far fa-file-pdf';
break;
case 'excel':
$icon = 'far fa-file-excel';
break;
default:
$icon = 'far fa-file-alt';
break;
}
return $icon;
}
/**
* @return bool
*/
public function canGenerateThumbnails(): bool
{
return RvMedia::canGenerateThumbnails($this->mime_type);
}
}