1 | <?php namespace VojtaSvoboda\Brands\Models; |
||
8 | class Brand 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_brands_brands'; |
||
19 | |||
20 | public $rules = [ |
||
21 | 'name' => 'required|max:255', |
||
22 | 'slug' => 'required|unique:vojtasvoboda_brands_brands', |
||
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 | 'logo' => ['System\Models\File'], |
||
33 | ]; |
||
34 | |||
35 | public $attachMany = [ |
||
36 | 'images' => ['System\Models\File'], |
||
37 | ]; |
||
38 | |||
39 | public $belongsToMany = [ |
||
40 | 'categories' => [ |
||
41 | 'VojtaSvoboda\Brands\Models\Category', |
||
42 | 'table' => 'vojtasvoboda_brands_brand_category', |
||
43 | 'order' => 'name asc', |
||
44 | 'scope' => 'isEnabled', |
||
45 | 'timestamps' => true, |
||
46 | ] |
||
47 | ]; |
||
48 | |||
49 | public function scopeIsEnabled($query) |
||
53 | |||
54 | /** |
||
55 | * Lists brands for the front end. |
||
56 | * |
||
57 | * @param \October\Rain\Database\Builder $query |
||
58 | * @param array $options Display options |
||
59 | * |
||
60 | * @return self |
||
61 | */ |
||
62 | public function scopeListFrontEnd($query, $options) |
||
110 | } |
||
111 |