1 | <?php namespace VojtaSvoboda\Reviews\Models; |
||
8 | class Category extends Model |
||
9 | { |
||
10 | use SoftDeletingTrait; |
||
11 | |||
12 | use SortableTrait; |
||
13 | |||
14 | use ValidationTrait; |
||
15 | |||
16 | public $implement = ['@RainLab.Translate.Behaviors.TranslatableModel']; |
||
17 | |||
18 | public $table = 'vojtasvoboda_reviews_categories'; |
||
19 | |||
20 | public $rules = [ |
||
21 | 'name' => 'required|max:255', |
||
22 | 'slug' => 'required|unique:vojtasvoboda_reviews_categories', |
||
23 | 'enabled' => 'boolean', |
||
24 | 'description' => 'max:10000', |
||
25 | ]; |
||
26 | |||
27 | public $translatable = ['name', 'slug', 'description']; |
||
28 | |||
29 | public $dates = ['created_at', 'updated_at', 'deleted_at']; |
||
30 | |||
31 | public $attachOne = [ |
||
32 | 'image' => ['System\Models\File'], |
||
33 | ]; |
||
34 | |||
35 | public $belongsToMany = [ |
||
36 | 'reviews' => ['VojtaSvoboda\Reviews\Models\Review', |
||
37 | 'table' => 'vojtasvoboda_reviews_review_category', |
||
38 | 'order' => 'name desc', |
||
39 | 'scope' => 'isEnabled', |
||
40 | 'timestamps' => true, |
||
41 | ], |
||
42 | ]; |
||
43 | |||
44 | public function scopeIsEnabled($query) |
||
48 | } |
||
49 |