1 | <?php namespace Arcanesoft\Blog\Models; |
||
22 | class Tag extends AbstractModel |
||
23 | { |
||
24 | /* ------------------------------------------------------------------------------------------------ |
||
25 | | Traits |
||
26 | | ------------------------------------------------------------------------------------------------ |
||
27 | */ |
||
28 | use SoftDeletes; |
||
29 | |||
30 | /* ------------------------------------------------------------------------------------------------ |
||
31 | | Properties |
||
32 | | ------------------------------------------------------------------------------------------------ |
||
33 | */ |
||
34 | /** |
||
35 | * The database table used by the model |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $table = 'tags'; |
||
40 | |||
41 | /** |
||
42 | * The attributes that are mass assignable |
||
43 | * |
||
44 | * @var array |
||
45 | */ |
||
46 | protected $fillable = ['name']; |
||
47 | |||
48 | /** |
||
49 | * The attributes that should be mutated to dates. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | protected $dates = ['deleted_at']; |
||
54 | |||
55 | /* ------------------------------------------------------------------------------------------------ |
||
56 | | Relationships |
||
57 | | ------------------------------------------------------------------------------------------------ |
||
58 | */ |
||
59 | /** |
||
60 | * Posts relationship. |
||
61 | * |
||
62 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
63 | */ |
||
64 | public function posts() |
||
68 | |||
69 | /* ------------------------------------------------------------------------------------------------ |
||
70 | | Getters & Setters |
||
71 | | ------------------------------------------------------------------------------------------------ |
||
72 | */ |
||
73 | /** |
||
74 | * Set the name attribute. |
||
75 | * |
||
76 | * @param string $name |
||
77 | */ |
||
78 | public function setNameAttribute($name) |
||
83 | |||
84 | /* ------------------------------------------------------------------------------------------------ |
||
85 | | Main Functions |
||
86 | | ------------------------------------------------------------------------------------------------ |
||
87 | */ |
||
88 | /** |
||
89 | * Get the categories options for select input. |
||
90 | * |
||
91 | * @return \Illuminate\Database\Eloquent\Collection |
||
92 | */ |
||
93 | public static function getSelectOptions() |
||
99 | |||
100 | /* ------------------------------------------------------------------------------------------------ |
||
101 | | Check Functions |
||
102 | | ------------------------------------------------------------------------------------------------ |
||
103 | */ |
||
104 | /** |
||
105 | * Check if tag has posts. |
||
106 | * |
||
107 | * @return bool |
||
108 | */ |
||
109 | public function hasPosts() |
||
113 | |||
114 | /* ------------------------------------------------------------------------------------------------ |
||
115 | | Other Functions |
||
116 | | ------------------------------------------------------------------------------------------------ |
||
117 | */ |
||
118 | /** |
||
119 | * Clear the cached tags. |
||
120 | */ |
||
121 | public static function clearCache() |
||
125 | } |
||
126 |