Passed
Push — dev5a ( c2cba2...4ce5a4 )
by Ron
07:44
created

TechTips::user()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace App;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\SoftDeletes;
8
9
use Carbon\Carbon;
10
11
class TechTips extends Model
12
{
13
    use SoftDeletes;
14
15
    protected $primaryKey = 'tip_id';
16
    protected $fillable   = ['user_id', 'updated_id', 'subject', 'tip_type_id', 'description', 'public', 'sticky'];
17
    protected $hidden     = ['public', 'user_id', 'updated_id', 'deleted_at'];
18
    protected $appends    = ['summary'];
19
    protected $casts      = [
20
        'created_at' => 'datetime:M d, Y',
21
        'updated_at' => 'datetime:M d, Y',
22
        'sticky'     => 'boolean',
23
    ];
24
25 16
    public function getSummaryAttribute()
26
    {
27 16
        return Str::words($this->description, 50);
28
    }
29
30 18
    public function systemTypes()
31
    {
32 18
        return $this->hasManyThrough('App\SystemTypes', 'App\TechTipSystems', 'tip_id', 'sys_id', 'tip_id', 'sys_id');
33
    }
34
35
    // public function user()
36
    // {
37
    //     return $this->hasOne('App\User', 'user_id', 'user_id');
38
    // }
39
40 12
    public function techTipTypes()
41
    {
42 12
        return $this->hasOne('App\TechTipTypes', 'tip_type_id', 'tip_type_id');
43
    }
44
45
    // public function techTipSystems()
46
    // {
47
    //     return $this->hasMany('App\TechTipSystems', 'tip_id', 'tip_id');
48
    // }
49
50 6
    public function techTipFiles()
51
    {
52 6
        return $this->hasMany('App\TechTipFiles', 'tip_id', 'tip_id');
53
    }
54
}
55