Passed
Push — dev6 ( c88035...50a53d )
by Ron
17:16
created

TechTip   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 31
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSummaryAttribute() 0 3 1
A EquipmentType() 0 3 1
A FileUploads() 0 3 1
A TechTipComment() 0 3 1
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Support\Str;
6
use Illuminate\Database\Eloquent\Model;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
9
class TechTip extends Model
10
{
11
    use HasFactory;
12
13
    protected $primaryKey = 'tip_id';
14
    protected $guarded    = ['tip_id', 'created_at', 'updated_at'];
15
    protected $hidden     = ['deleted_at', 'tip_type_id', 'updated_id', 'user_id'];
16
    protected $appends    = ['summary'];
17
    protected $casts      = [
18
        'created_at' => 'datetime:M d, Y',
19
        'updated_at' => 'datetime:M d, Y',
20
    ];
21
22
    public function getSummaryAttribute()
23
    {
24
        return Str::words($this->details, 50);
25
    }
26
27
    public function EquipmentType()
28
    {
29
        return $this->hasManyThrough(EquipmentType::class, TechTipEquipment::class, 'tip_id', 'equip_id', 'tip_id', 'equip_id');
30
    }
31
32
    public function FileUploads()
33
    {
34
        return $this->hasManyThrough(FileUploads::class, TechTipFile::class, 'tip_id', 'file_id', 'tip_id', 'file_id');
35
    }
36
37
    public function TechTipComment()
38
    {
39
        return $this->hasMany(TechTipComment::class, 'tip_id', 'tip_id');
40
    }
41
}
42