Changeset 0a1fb54 for app/Models


Ignore:
Timestamp:
11/23/21 22:01:52 (3 years ago)
Author:
beratkjufliju <kufliju@…>
Branches:
master
Children:
dbc5976
Parents:
4d73966
Message:

bug fixes

Location:
app/Models
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • app/Models/Department.php

    r4d73966 r0a1fb54  
    99class Department extends Model
    1010{
    11     use Notifiable;
    1211    use HasFactory;
    1312
     
    2019    ];
    2120
    22     public function getCreatedByName()
    23     {
    24         return User::where('id', $this->user_id)->pluck('username')->first();
    25     }
    26 
    2721    public function folder(){
    2822        return $this->hasMany(Folder::class);
    2923    }
    3024
    31 //    public function getDeptId(){
    32 //        return Department::where('id', $this->id)->get();
    33 //    }
     25    public function user(){
     26        return $this->belongsTo(User::class);
     27    }
     28
    3429}
  • app/Models/File.php

    r4d73966 r0a1fb54  
    1212
    1313    protected $table = "files";
    14     protected $fillable = ["name", "location", "document_id"];
     14    protected $fillable = ["name", "location", "folder_id"];
    1515
    1616    public function folder()
     
    2121    public function getSize($location)
    2222    {
    23         $fileSize = Storage::disk('uploads')->size($location) / 1024 / 1024;
     23        $fileSize = Storage::disk('local')->size($location) / 1024 / 1024;
    2424        $fileSize = round($fileSize, 2);
    2525        return $fileSize;
  • app/Models/User.php

    r4d73966 r0a1fb54  
    134134    }
    135135
     136    public function getCreatedByUsername()
     137    {
     138        return User::where('id', $this->created_by)->pluck('username')->first();
     139    }
     140
    136141    public function getCreatedByName()
    137142    {
    138         return User::where('id', $this->created_by)->pluck('username')->first();
     143        $name = User::where('id', $this->created_by)->pluck('name')->first();
     144        $surname = User::where('id', $this->created_by)->pluck('surname')->first();
     145
     146        return $name . " " . $surname;
    139147    }
    140148
     
    142150        return $this->hasMany(Folder::class);
    143151    }
     152
     153    public function department() {
     154        return $this->hasMany(Department::class);
     155    }
    144156}
Note: See TracChangeset for help on using the changeset viewer.