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