FileUpload::getFileNameAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Ikechukwukalu\Clamavfileupload\Models;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
use Illuminate\Support\Facades\Crypt;
9
10
class FileUpload extends Model
11
{
12
    use HasFactory, SoftDeletes;
13
14
    protected $table = "file_uploads";
15
16
    protected $fillable = [
17
        'ref',
18
        'name',
19
        'file_name',
20
        'size',
21
        'extension',
22
        'disk',
23
        'mime_type',
24
        'path',
25
        'relative_path',
26
        'url',
27
        'folder',
28
        'hashed',
29
    ];
30
31
    protected $casts = [
32
        'hashed' => 'boolean'
33
    ];
34
35
    protected function getFileNameAttribute($value)
36
    {
37
        if ($this->hashed) {
38
            return Crypt::decryptString($value);
39
        }
40
41
        return $value;
42
    }
43
44
    protected function getPathAttribute($value)
45
    {
46
        if ($this->hashed) {
47
            return Crypt::decryptString($value);
48
        }
49
50
        return $value;
51
    }
52
53
54
    protected function getRelativePathAttribute($value)
55
    {
56
        if ($this->hashed) {
57
            return Crypt::decryptString($value);
58
        }
59
60
        return $value;
61
    }
62
63
    protected function getUrlAttribute($value)
64
    {
65
        if ($this->hashed) {
66
            return Crypt::decryptString($value);
67
        }
68
69
        return $value;
70
    }
71
72
}
73