Test Failed
Push — dev6 ( e3f62b...d58043 )
by Ron
17:13
created

CustomerFile::getUploadedByAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
9
class CustomerFile extends Model
10
{
11
    use HasFactory;
12
    use SoftDeletes;
13
14
    protected $primaryKey = 'cust_file_id';
15
    protected $guarded    = ['cust_file_id', 'created_at', 'updated_at'];
16
    protected $hidden     = ['cust_id', 'file_type_id', 'created_at', 'user_id', 'deleted_at'];
17
    protected $appends    = ['uploaded_by', 'file_type'];
18
    protected $casts      = [
19
        'created_at' => 'datetime:M d, Y',
20
        'updated_at' => 'datetime:M d, Y',
21
        'deleted_at' => 'datetime:M d, Y',
22
        'shared'     => 'boolean',
23
    ];
24
25
26
    /*
27
    *   Each file is attached to a specific file entry
28
    */
29 2
    public function FileUpload()
30
    {
31 2
        return $this->hasOne(FileUploads::class, 'file_id', 'file_id');
32
    }
33
34
    /*
35
    *   Full name of the user that uploaded the file
36
    */
37 3
    public function getUploadedByAttribute()
38
    {
39 3
        return User::find($this->user_id)->full_name;
40
    }
41
42
    /*
43
    *   Type of file that was uploaded (i.e. Backup, Site Map, etc)
44
    */
45 3
    public function getFileTypeAttribute()
46
    {
47 3
        return CustomerFileType::find($this->file_type_id)->description;
48
    }
49
}
50