source: app/Models/File.php@ ff5b46e

develop
Last change on this file since ff5b46e 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
Line 
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Factories\HasFactory;
6use Illuminate\Database\Eloquent\Model;
7use Illuminate\Support\Facades\Storage;
8
9class File extends Model
10{
11 use HasFactory;
12
13 protected $table = "files";
14 protected $fillable = ["name", "location", "document_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('uploads')->size($location) / 1024 / 1024;
24 $fileSize = round($fileSize, 2);
25 return $fileSize;
26 }
27}
Note: See TracBrowser for help on using the repository browser.