1 | <?php |
||
12 | abstract class BookableRate extends Model |
||
13 | { |
||
14 | use ValidatingTrait; |
||
15 | use CacheableEloquent; |
||
16 | |||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | protected $fillable = [ |
||
21 | 'bookable_id', |
||
22 | 'bookable_type', |
||
23 | 'range', |
||
24 | 'range_from', |
||
25 | 'range_to', |
||
26 | 'base_cost', |
||
27 | 'base_cost_modifier', |
||
28 | 'unit_cost', |
||
29 | 'unit_cost_modifier', |
||
30 | 'priority', |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | protected $casts = [ |
||
37 | 'bookable_id' => 'integer', |
||
38 | 'bookable_type' => 'string', |
||
39 | 'range' => 'string', |
||
40 | 'range_from' => 'string', |
||
41 | 'range_to' => 'string', |
||
42 | 'base_cost' => 'float', |
||
43 | 'base_cost_modifier' => 'string', |
||
44 | 'unit_cost' => 'float', |
||
45 | 'unit_cost_modifier' => 'string', |
||
46 | 'priority' => 'integer', |
||
47 | ]; |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | protected $observables = [ |
||
53 | 'validating', |
||
54 | 'validated', |
||
55 | ]; |
||
56 | |||
57 | /** |
||
58 | * The default rules that the model will validate against. |
||
59 | * |
||
60 | * @var array |
||
61 | */ |
||
62 | protected $rules = [ |
||
63 | 'bookable_id' => 'required|integer', |
||
64 | 'bookable_type' => 'required|string', |
||
65 | 'range' => 'required|string|in:unit,date,month,week,day,datetime,time,time-sun,time-mon,time-tue,time-wed,time-thu,time-fri,time-sat', |
||
|
|||
66 | 'range_from' => 'required|string|max:150', |
||
67 | 'range_to' => 'required|string|max:150', |
||
68 | 'base_cost' => 'required|numeric', |
||
69 | 'base_cost_modifier' => 'required|string|in:+,-,×,÷', |
||
70 | 'unit_cost' => 'required|numeric', |
||
71 | 'unit_cost_modifier' => 'required|string|in:+,-,×,÷', |
||
72 | 'priority' => 'nullable|integer', |
||
73 | ]; |
||
74 | |||
75 | /** |
||
76 | * Whether the model should throw a |
||
77 | * ValidationException if it fails validation. |
||
78 | * |
||
79 | * @var bool |
||
80 | */ |
||
81 | protected $throwValidationExceptions = true; |
||
82 | |||
83 | /** |
||
84 | * Create a new Eloquent model instance. |
||
85 | * |
||
86 | * @param array $attributes |
||
87 | */ |
||
88 | public function __construct(array $attributes = []) |
||
94 | |||
95 | /** |
||
96 | * Get the owning resource model. |
||
97 | * |
||
98 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
99 | */ |
||
100 | public function bookable(): MorphTo |
||
104 | } |
||
105 |
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.