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