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
|
|
|
|