Profile::getBloodGroupAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 1
dl 0
loc 12
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Pratiksh\Adminetic\Models\Admin;
4
5
use App\Models\User;
0 ignored issues
show
Bug introduced by
The type App\Models\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Illuminate\Database\Eloquent\Factories\HasFactory;
7
use Illuminate\Database\Eloquent\Model;
8
9
class Profile extends Model
10
{
11
    use HasFactory;
12
13
    protected $guarded = [];
14
15
    // Attribute Casting
16
    protected $casts = [
17
        'phone_no' => 'array',
18
    ];
19
20
    // Accessors
21
    public function getStatusAttribute($attribute)
22
    {
23
        return isset($this->status) ? [
24
            1 => 'Active',
25
            2 => 'Inactive',
26
            3 => 'Blocked',
27
        ][$attribute] : null;
28
    }
29
30
    public function getBloodGroupAttribute($attribute)
31
    {
32
        return isset($this->blood_group) ? [
33
            1 => 'A',
34
            2 => 'B',
35
            3 => 'A+',
36
            4 => 'B+',
37
            5 => 'AB',
38
            6 => 'AB+',
39
            7 => 'O+',
40
            8 => 'O-',
41
        ][$attribute] : null;
42
    }
43
44
    public function getMartialStatusAttribute($attribute)
45
    {
46
        return isset($this->martial_status) ? [
47
            1 => 'Married',
48
            2 => 'Unmarried',
49
            3 => 'Divorced',
50
            4 => 'Widowed',
51
        ][$attribute] : null;
52
    }
53
54
    // Relation
55
    public function user()
56
    {
57
        return $this->belongsTo(User::class, 'user_id');
58
    }
59
}
60