source:
app/Models/File.php@
c6b84df
Last change on this file since c6b84df was c6b84df, checked in by , 3 years ago | |
---|---|
|
|
File size: 521 bytes |
Rev | Line | |
---|---|---|
[24a616f] | 1 | <?php |
2 | ||
3 | namespace App\Models; | |
4 | ||
5 | use Illuminate\Database\Eloquent\Model; | |
[ea7b12a] | 6 | use Illuminate\Support\Facades\Storage; |
[24a616f] | 7 | |
8 | class File extends Model | |
9 | { | |
10 | protected $table = "files"; | |
[ea7b12a] | 11 | protected $fillable = ["name", "location", "document_id"]; |
[24a616f] | 12 | |
[c6b84df] | 13 | public function folder() |
[24a616f] | 14 | { |
[c6b84df] | 15 | return $this->belongsTo(Folder::class); |
[24a616f] | 16 | } |
[ea7b12a] | 17 | |
18 | public function getSize($location) | |
19 | { | |
[c6b84df] | 20 | $fileSize = Storage::disk('uploads')->size($location) / 1024 / 1024; |
[ea7b12a] | 21 | $fileSize = round($fileSize, 2); |
22 | return $fileSize; | |
23 | } | |
[24a616f] | 24 | } |
Note:
See TracBrowser
for help on using the repository browser.