Passed
Push — dev6 ( 811cb3...58f07d )
by Ron
13:14
created

UserCustomerRecent::getSlugAttribute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 2
nc 2
nop 0
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Factories\HasFactory;
6
use Illuminate\Database\Eloquent\Model;
7
8
class UserCustomerRecent extends Model
9
{
10
    use HasFactory;
11
12
    protected $guarded = ['id', 'updated_at', 'created_at'];
13
    protected $hidden  = ['id', 'user_id', 'created_at', 'Customer'];
14
    protected $appends      = ['name', 'slug'];
15
16
    public function Customer()
17
    {
18
        return $this->belongsTo(Customer::class, 'cust_id', 'cust_id');
19
    }
20
21
    public function getNameAttribute()
22
    {
23
        return isset($this->Customer->name) ? $this->Customer->name : null;
24
    }
25
26
    public function getSlugAttribute()
27
    {
28
        return isset($this->Customer->slug) ? $this->Customer->slug : null;
29
    }
30
}
31