|
Last change
on this file since 1e31937 was 0a1fb54, checked in by beratkjufliju <kufliju@…>, 4 years ago |
|
bug fixes
|
-
Property mode
set to
100644
|
|
File size:
593 bytes
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | namespace App\Models;
|
|---|
| 4 |
|
|---|
| 5 | use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|---|
| 6 | use Illuminate\Database\Eloquent\Model;
|
|---|
| 7 | use Illuminate\Support\Facades\Storage;
|
|---|
| 8 |
|
|---|
| 9 | class File extends Model
|
|---|
| 10 | {
|
|---|
| 11 | use HasFactory;
|
|---|
| 12 |
|
|---|
| 13 | protected $table = "files";
|
|---|
| 14 | protected $fillable = ["name", "location", "folder_id"];
|
|---|
| 15 |
|
|---|
| 16 | public function folder()
|
|---|
| 17 | {
|
|---|
| 18 | return $this->belongsTo(Folder::class);
|
|---|
| 19 | }
|
|---|
| 20 |
|
|---|
| 21 | public function getSize($location)
|
|---|
| 22 | {
|
|---|
| 23 | $fileSize = Storage::disk('local')->size($location) / 1024 / 1024;
|
|---|
| 24 | $fileSize = round($fileSize, 2);
|
|---|
| 25 | return $fileSize;
|
|---|
| 26 | }
|
|---|
| 27 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.