CustomerNote   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 16
c 2
b 0
f 0
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAuthorAttribute() 0 3 1
A getUpdatedAuthorAttribute() 0 4 2
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 CustomerNote extends Model
10
{
11
    use HasFactory;
12
    use SoftDeletes;
13
14
    protected $primaryKey = 'note_id';
15
    protected $guarded    = ['updated_at', 'created_at'];
16
    protected $appends    = ['author', 'updated_author'];
17
    protected $hidden     = ['created_by', 'updated_by', 'deleted_at'];
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
        'urgent'     => 'boolean',
23
        'shared'     => 'boolean',
24
    ];
25
26
    /*
27
    *   Name of the user who created the note
28
    */
29
    public function getAuthorAttribute()
30
    {
31
        return User::find($this->created_by)->full_name;
32
    }
33
34
    /*
35
    *   Name of the user who most recently updated the note
36
    */
37
    public function getUpdatedAuthorAttribute()
38
    {
39
        $user = User::find($this->updated_by);
40
        return $user ? $user->full_name : null;
41
    }
42
}
43