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

UserTechTipRecent   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 8
c 1
b 0
f 0
dl 0
loc 21
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubjectAttribute() 0 3 2
A TechTip() 0 3 1
A getSlugAttribute() 0 3 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 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