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