1 | <?php namespace Arcanesoft\Blog\Models; |
||
23 | class Tag extends AbstractModel |
||
24 | { |
||
25 | /* ----------------------------------------------------------------- |
||
26 | | Traits |
||
27 | | ----------------------------------------------------------------- |
||
28 | */ |
||
29 | |||
30 | use SoftDeletes, |
||
31 | HasTranslations; |
||
32 | |||
33 | /* ----------------------------------------------------------------- |
||
34 | | Properties |
||
35 | | ----------------------------------------------------------------- |
||
36 | */ |
||
37 | |||
38 | /** |
||
39 | * The database table used by the model |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $table = 'tags'; |
||
44 | |||
45 | /** |
||
46 | * The attributes that are mass assignable |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $fillable = ['name']; |
||
51 | |||
52 | /** |
||
53 | * The attributes that should be mutated to dates. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | protected $dates = ['deleted_at']; |
||
58 | |||
59 | /* ----------------------------------------------------------------- |
||
60 | | Relationships |
||
61 | | ----------------------------------------------------------------- |
||
62 | */ |
||
63 | |||
64 | /** |
||
65 | * Posts relationship. |
||
66 | * |
||
67 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
68 | */ |
||
69 | public function posts() |
||
73 | |||
74 | /* ----------------------------------------------------------------- |
||
75 | | Getters & Setters |
||
76 | | ----------------------------------------------------------------- |
||
77 | */ |
||
78 | |||
79 | /** |
||
80 | * Set the name attribute. |
||
81 | * |
||
82 | * @param string $name |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function setNameAttribute($name) |
||
90 | |||
91 | /** |
||
92 | * Set the slug attribute. |
||
93 | * |
||
94 | * @param string $name |
||
95 | * |
||
96 | * @return string |
||
97 | */ |
||
98 | public function setSlugAttribute($name) |
||
102 | |||
103 | /** |
||
104 | * Get the translatable attributes. |
||
105 | * |
||
106 | * @return array |
||
107 | */ |
||
108 | public function getTranslatableAttributes() |
||
112 | |||
113 | /* ----------------------------------------------------------------- |
||
114 | | Main Methods |
||
115 | | ----------------------------------------------------------------- |
||
116 | */ |
||
117 | |||
118 | /** |
||
119 | * Create a new tag. |
||
120 | * |
||
121 | * @param array $attributes |
||
122 | * |
||
123 | * @return self |
||
124 | */ |
||
125 | public static function createOne(array $attributes) |
||
135 | |||
136 | /** |
||
137 | * Update the current tag. |
||
138 | * |
||
139 | * @param array $attributes |
||
140 | * |
||
141 | * @return self |
||
142 | */ |
||
143 | public function updateOne(array $attributes) |
||
151 | |||
152 | /** |
||
153 | * Get the categories options for select input. |
||
154 | * |
||
155 | * @return \Illuminate\Database\Eloquent\Collection |
||
156 | */ |
||
157 | public static function getSelectOptions() |
||
165 | |||
166 | /* ----------------------------------------------------------------- |
||
167 | | Check Methods |
||
168 | | ----------------------------------------------------------------- |
||
169 | */ |
||
170 | |||
171 | /** |
||
172 | * Check if tag has posts. |
||
173 | * |
||
174 | * @return bool |
||
175 | */ |
||
176 | public function hasPosts() |
||
180 | |||
181 | /* ----------------------------------------------------------------- |
||
182 | | Other Methods |
||
183 | | ----------------------------------------------------------------- |
||
184 | */ |
||
185 | |||
186 | /** |
||
187 | * Clear the cached tags. |
||
188 | */ |
||
189 | public static function clearCache() |
||
193 | } |
||
194 |