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

UserTechTipRecent::TechTip()   A

Complexity

Conditions 1
Paths 1

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 1
nc 1
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 UserTechTipRecent extends Model
9
{
10
    use HasFactory;
11
12
    protected $guarded = ['id', 'updated_at', 'created_at'];
13
    protected $hidden  = ['id', 'user_id', 'created_at', 'TechTip'];
14
    protected $appends = ['subject', 'slug'];
15
16
    public function TechTip()
17
    {
18
        return $this->belongsTo(TechTip::class, 'tip_id', 'tip_id');
19
    }
20
21
    public function getSubjectAttribute()
22
    {
23
        return isset($this->TechTip->subject) ? $this->TechTip->subject : null;
24
    }
25
26
    public function getSlugAttribute()
27
    {
28
        return isset($this->TechTip->slug) ? $this->TechTip->slug : null;
29
    }
30
}
31