Changeset ea7b12a for app/Models


Ignore:
Timestamp:
10/19/21 17:46:21 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
develop, master
Children:
6b95845
Parents:
b9c4a92
Message:

added files crud in table

Location:
app/Models
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • app/Models/Document.php

    rb9c4a92 rea7b12a  
    2222    }
    2323
    24     public function ago() {
    25         return Carbon::parse($this->created_at)->diffForHumans();
    26     }
    27 
    2824    public function files()
    2925    {
  • app/Models/File.php

    rb9c4a92 rea7b12a  
    44
    55use Illuminate\Database\Eloquent\Model;
     6use Illuminate\Support\Facades\Storage;
    67
    78class File extends Model
    89{
    910    protected $table = "files";
    10     protected $fillable = ["link", "document_id"];
     11    protected $fillable = ["name", "location", "document_id"];
    1112
    1213    public function document()
     
    1415        return $this->belongsTo(Document::class);
    1516    }
     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    }
    1624}
Note: See TracChangeset for help on using the changeset viewer.