1 | <?php |
||
17 | abstract class Bookable extends Model implements Sortable |
||
18 | { |
||
19 | use HasSlug; |
||
20 | use BookableTrait; |
||
21 | use SortableTrait; |
||
22 | use HasTranslations; |
||
23 | use ValidatingTrait; |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | protected $fillable = [ |
||
29 | 'slug', |
||
30 | 'name', |
||
31 | 'description', |
||
32 | 'is_active', |
||
33 | 'base_cost', |
||
34 | 'unit_cost', |
||
35 | 'currency', |
||
36 | 'unit', |
||
37 | 'maximum_units', |
||
38 | 'minimum_units', |
||
39 | 'is_cancelable', |
||
40 | 'is_recurring', |
||
41 | 'sort_order', |
||
42 | 'capacity', |
||
43 | 'style', |
||
44 | ]; |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | protected $casts = [ |
||
50 | 'slug' => 'string', |
||
51 | 'name' => 'string', |
||
52 | 'description' => 'string', |
||
53 | 'is_active' => 'boolean', |
||
54 | 'base_cost' => 'float', |
||
55 | 'unit_cost' => 'float', |
||
56 | 'currency' => 'string', |
||
57 | 'unit' => 'string', |
||
58 | 'maximum_units' => 'integer', |
||
59 | 'minimum_units' => 'integer', |
||
60 | 'is_cancelable' => 'boolean', |
||
61 | 'is_recurring' => 'boolean', |
||
62 | 'sort_order' => 'integer', |
||
63 | 'capacity' => 'integer', |
||
64 | 'style' => 'string', |
||
65 | 'deleted_at' => 'datetime', |
||
66 | ]; |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | protected $observables = [ |
||
72 | 'validating', |
||
73 | 'validated', |
||
74 | ]; |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public $translatable = [ |
||
80 | 'name', |
||
81 | 'description', |
||
82 | ]; |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public $sortable = [ |
||
88 | 'order_column_name' => 'sort_order', |
||
89 | ]; |
||
90 | |||
91 | /** |
||
92 | * The default rules that the model will validate against. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $rules = []; |
||
97 | |||
98 | /** |
||
99 | * Create a new Eloquent model instance. |
||
100 | * |
||
101 | * @param array $attributes |
||
102 | */ |
||
103 | public function __construct(array $attributes = []) |
||
125 | |||
126 | /** |
||
127 | * Get the active resources. |
||
128 | * |
||
129 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
130 | * |
||
131 | * @return \Illuminate\Database\Eloquent\Builder |
||
132 | */ |
||
133 | public function scopeActive(Builder $builder): Builder |
||
137 | |||
138 | /** |
||
139 | * Get the inactive resources. |
||
140 | * |
||
141 | * @param \Illuminate\Database\Eloquent\Builder $builder |
||
142 | * |
||
143 | * @return \Illuminate\Database\Eloquent\Builder |
||
144 | */ |
||
145 | public function scopeInactive(Builder $builder): Builder |
||
149 | |||
150 | /** |
||
151 | * Get the options for generating the slug. |
||
152 | * |
||
153 | * @return \Spatie\Sluggable\SlugOptions |
||
154 | */ |
||
155 | public function getSlugOptions(): SlugOptions |
||
162 | |||
163 | /** |
||
164 | * Activate the resource. |
||
165 | * |
||
166 | * @return $this |
||
167 | */ |
||
168 | public function activate() |
||
174 | |||
175 | /** |
||
176 | * Deactivate the resource. |
||
177 | * |
||
178 | * @return $this |
||
179 | */ |
||
180 | public function deactivate() |
||
186 | } |
||
187 |