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

TechTipComments   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A User() 0 3 1
A getEditAttribute() 0 8 3
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