Passed
Push — dev5a ( 915c64...c2cba2 )
by Ron
07:58
created

TechTipComments::getEditAttribute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 3
nop 0
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Support\Facades\Auth;
7
8
class TechTipComments extends Model
9
{
10
    protected $primaryKey = 'comment_id';
11
    protected $fillable   = ['tip_id', 'user_id', 'comment'];
12
    protected $hidden     = ['user_id'];
13
    protected $appends    = ['edit'];
14
    protected $casts      = [
15
        'created_at' => 'datetime:M d, Y',
16
        'updated_at' => 'datetime:M d, Y',
17
    ];
18
19 4
    public function User()
20
    {
21 4
        return $this->hasOne('App\User', 'user_id', 'user_id');
22
    }
23
24 4
    public function getEditAttribute()
25
    {
26 4
        if(Auth::check())
27
        {
28 2
            return Auth::user()->user_id == $this->user_id ? true : false;
29
        }
30
31 2
        return false;
32
    }
33
}
34