Test Setup Failed
Push — dev6 ( 01d104...b652d0 )
by Ron
17:32
created

CustomerFile   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
c 1
b 0
f 0
dl 0
loc 28
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileTypeAttribute() 0 3 1
A FileUpload() 0 3 1
A getUploadedByAttribute() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
8
class CustomerFile extends Model
9
{
10
    use HasFactory;
11
12
    protected $primaryKey = 'cust_file_id';
13
    protected $guarded    = ['cust_file_id', 'created_at', 'updated_at'];
14
    protected $hidden     = ['cust_id', 'file_type_id', 'created_at', 'user_id'];
15
    protected $appends    = ['uploaded_by', 'file_type'];
16
    protected $casts      = [
17
        'created_at' => 'datetime:M d, Y',
18
        'updated_at' => 'datetime:M d, Y',
19
        'shared'     => 'boolean',
20
    ];
21
22
23
    public function FileUpload()
24
    {
25
        return $this->hasOne(FileUploads::class, 'file_id', 'file_id');
26
    }
27
28
    public function getUploadedByAttribute()
29
    {
30
        return User::find($this->user_id)->full_name;
31
    }
32
33
    public function getFileTypeAttribute()
34
    {
35
        return CustomerFileType::find($this->file_type_id)->description;
36
    }
37
}
38