Test Setup Failed
Push — dev6 ( 81193f...01d104 )
by Ron
22:34
created

CustomerNote   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 14
c 1
b 0
f 0
dl 0
loc 24
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\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
8
class CustomerNote extends Model
9
{
10
    use HasFactory;
11
12
    protected $primaryKey = 'note_id';
13
    protected $guarded    = ['updated_at', 'created_at'];
14
    protected $appends    = ['author', 'updated_author'];
15
    protected $hidden     = ['created_by', 'updated_by'];
16
    protected $casts      = [
17
        'created_at' => 'datetime:M d, Y',
18
        'updated_at' => 'datetime:M d, Y',
19
        'urgent'     => 'boolean',
20
        'shared'     => 'boolean',
21
    ];
22
23
    public function getAuthorAttribute()
24
    {
25
        return User::find($this->created_by)->full_name;
26
    }
27
28
    public function getUpdatedAuthorAttribute()
29
    {
30
        $user = User::find($this->updated_by);
31
        return $user ? $user->full_name : null;
32
    }
33
}
34