Display Uploaded Files

This commit is contained in:
R
2023-02-15 12:30:35 +07:00
parent 27523b8cce
commit 5d4033a9ca
13 changed files with 149 additions and 28 deletions

View File

@@ -16,10 +16,20 @@ class File extends Model
'fileable_id',
'type',
'name',
'original_name',
'extension',
'path',
];
protected $hidden = [
'created_at',
'updated_at',
'deleted_at',
'created_by',
'updated_by',
'deleted_by',
];
public $appends = [
'url'
];
@@ -28,7 +38,7 @@ class File extends Model
'import-temp' => 'import-temp/',
'avatar' => 'user-avatar/',
'dataDiri' => 'data-diri/',
''
'claim' => 'claim/'
];
public function fileable()
@@ -46,6 +56,11 @@ class File extends Model
return $type . '-' . $id . '-' . Str::random(10);
}
public function getNameAttribute($value)
{
return !empty($this->original_name) ? $this->original_name : ($value . '.' . $this->extension);
}
public function getUrlAttribute()
{
return url(Storage::url($this->path));