source: app/Models/File.php@ cb88e9f

develop
Last change on this file since cb88e9f was 4b7e2d3, checked in by beratkjufliju <kufliju@…>, 3 years ago

bug fixes, edited export, added fileSeeder for DB testing

  • Property mode set to 100644
File size: 597 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";
[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.