source: app/Models/File.php@ 6b95845

develop
Last change on this file since 6b95845 was ea7b12a, checked in by beratkjufliju <kufliju@…>, 3 years ago

added files crud in table

  • Property mode set to 100644
File size: 523 bytes
RevLine 
[24a616f]1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
[ea7b12a]6use Illuminate\Support\Facades\Storage;
[24a616f]7
8class File extends Model
9{
10 protected $table = "files";
[ea7b12a]11 protected $fillable = ["name", "location", "document_id"];
[24a616f]12
13 public function document()
14 {
15 return $this->belongsTo(Document::class);
16 }
[ea7b12a]17
18 public function getSize($location)
19 {
20 $fileSize = Storage::disk('local')->size($location) / 1024 / 1024;
21 $fileSize = round($fileSize, 2);
22 return $fileSize;
23 }
[24a616f]24}
Note: See TracBrowser for help on using the repository browser.