|
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
|
|
|
|