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

TechTips   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 42
ccs 8
cts 12
cp 0.6667
rs 10
c 1
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A techTipSystems() 0 3 1
A user() 0 3 1
A systemTypes() 0 3 1
A techTipTypes() 0 3 1
A getSummaryAttribute() 0 3 1
A techTipFiles() 0 3 1
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 14
    public function getSummaryAttribute()
26
    {
27 14
        return Str::words($this->description, 50);
28
    }
29
30 16
    public function systemTypes()
31
    {
32 16
        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 4
    public function techTipFiles()
51
    {
52 4
        return $this->hasMany('App\TechTipFiles', 'tip_id', 'tip_id');
53
    }
54
}
55