1 | <?php namespace Arcanesoft\Blog\Models; |
||
24 | abstract class AbstractTaxonomy extends AbstractModel |
||
25 | { |
||
26 | /* ----------------------------------------------------------------- |
||
27 | | Traits |
||
28 | | ----------------------------------------------------------------- |
||
29 | */ |
||
30 | |||
31 | use SoftDeletes, |
||
32 | HasTranslations; |
||
33 | |||
34 | /* ----------------------------------------------------------------- |
||
35 | | Properties |
||
36 | | ----------------------------------------------------------------- |
||
37 | */ |
||
38 | |||
39 | /** |
||
40 | * The attributes that are mass assignable |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $fillable = ['name', 'slug']; |
||
45 | |||
46 | /** |
||
47 | * The attributes that should be mutated to dates. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $dates = ['deleted_at']; |
||
52 | |||
53 | /** |
||
54 | * The attributes that should be cast to native types. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $casts = [ |
||
59 | 'id' => 'integer', |
||
60 | ]; |
||
61 | |||
62 | /* ----------------------------------------------------------------- |
||
63 | | Getters & Setters |
||
64 | | ----------------------------------------------------------------- |
||
65 | */ |
||
66 | |||
67 | /** |
||
68 | * Set the name attribute. |
||
69 | * |
||
70 | * @param string $name |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | 26 | public function setNameAttribute($name) |
|
78 | |||
79 | /** |
||
80 | * Set the slug attribute. |
||
81 | * |
||
82 | * @param string $name |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | 26 | public function setSlugAttribute($name) |
|
90 | |||
91 | /** |
||
92 | * Get the translatable attributes. |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | 26 | public function getTranslatableAttributes() |
|
100 | |||
101 | /* ----------------------------------------------------------------- |
||
102 | | Main Methods |
||
103 | | ----------------------------------------------------------------- |
||
104 | */ |
||
105 | |||
106 | /** |
||
107 | * Create a new taxonomy (category or tag). |
||
108 | * |
||
109 | * @param array $attributes |
||
110 | * |
||
111 | * @return static |
||
112 | */ |
||
113 | public static function createOne(array $attributes) |
||
121 | |||
122 | /** |
||
123 | * Create many taxonomies (categories or tags). |
||
124 | * |
||
125 | * @param array $taxonomies |
||
126 | * |
||
127 | * @return \Illuminate\Support\Collection |
||
128 | */ |
||
129 | public static function createMany(array $taxonomies) |
||
135 | |||
136 | /** |
||
137 | * Update the current taxonomy (category or tag). |
||
138 | * |
||
139 | * @param array $attributes |
||
140 | * |
||
141 | * @return static |
||
142 | */ |
||
143 | 8 | public function updateOne(array $attributes) |
|
149 | |||
150 | /* ----------------------------------------------------------------- |
||
151 | | Check Methods |
||
152 | | ----------------------------------------------------------------- |
||
153 | */ |
||
154 | |||
155 | /** |
||
156 | * Check if tag has posts. |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | 4 | public function hasPosts() |
|
164 | |||
165 | /** |
||
166 | * Check if the category is deletable. |
||
167 | * |
||
168 | * @return bool |
||
169 | */ |
||
170 | 4 | public function isDeletable() |
|
174 | |||
175 | /* ----------------------------------------------------------------- |
||
176 | | Other Methods |
||
177 | | ----------------------------------------------------------------- |
||
178 | */ |
||
179 | |||
180 | /** |
||
181 | * Fill the model with an array of attributes. |
||
182 | * |
||
183 | * @param array $attributes |
||
184 | * |
||
185 | * @return static |
||
186 | */ |
||
187 | 24 | protected function populate(array $attributes) |
|
199 | } |
||
200 |