FileUpload   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 8
eloc 30
c 3
b 0
f 0
dl 0
loc 60
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getRelativePathAttribute() 0 7 2
A getUrlAttribute() 0 7 2
A getFileNameAttribute() 0 7 2
A getPathAttribute() 0 7 2
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