Passed
Push — dev5a ( 2c238c...96dd50 )
by Ron
07:38
created

TechTips   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 60%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 37
ccs 6
cts 10
cp 0.6
rs 10
wmc 5

5 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
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 12
    public function systemTypes()
31
    {
32 12
        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