source: app/Models/File.php@ 79aa35c

Last change on this file since 79aa35c was 0a1fb54, checked in by beratkjufliju <kufliju@…>, 3 years ago

bug fixes

  • Property mode set to 100644
File size: 593 bytes
RevLine 
[24a616f]1<?php
2
3namespace App\Models;
4
[4b7e2d3]5use Illuminate\Database\Eloquent\Factories\HasFactory;
[24a616f]6use Illuminate\Database\Eloquent\Model;
[ea7b12a]7use Illuminate\Support\Facades\Storage;
[24a616f]8
9class File extends Model
10{
[4b7e2d3]11 use HasFactory;
12
[24a616f]13 protected $table = "files";
[0a1fb54]14 protected $fillable = ["name", "location", "folder_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 {
[0a1fb54]23 $fileSize = Storage::disk('local')->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.