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