1 | <?php |
||
37 | class Price extends Model |
||
38 | { |
||
39 | use ValidatingTrait; |
||
40 | use CacheableEloquent; |
||
41 | |||
42 | /** |
||
43 | * {@inheritdoc} |
||
44 | */ |
||
45 | protected $fillable = [ |
||
46 | 'bookable_id', |
||
47 | 'bookable_type', |
||
48 | 'percentage', |
||
49 | 'weekday', |
||
50 | 'starts_at', |
||
51 | 'ends_at', |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | protected $casts = [ |
||
58 | 'bookable_id' => 'integer', |
||
59 | 'bookable_type' => 'string', |
||
60 | 'percentage' => 'float', |
||
61 | 'weekday' => 'string', |
||
62 | 'starts_at' => 'string', |
||
63 | 'ends_at' => 'string', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | protected $observables = [ |
||
70 | 'validating', |
||
71 | 'validated', |
||
72 | ]; |
||
73 | |||
74 | /** |
||
75 | * The default rules that the model will validate against. |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | protected $rules = [ |
||
80 | 'bookable_id' => 'required|integer', |
||
81 | 'bookable_type' => 'required|string', |
||
82 | 'percentage' => 'required|numeric|min:-100|max:100', |
||
83 | 'weekday' => 'required|string|in:sun,mon,tue,wed,thu,fri,sat', |
||
84 | 'starts_at' => 'required|date_format:"H:i:s"', |
||
85 | 'ends_at' => 'required|date_format:"H:i:s"', |
||
86 | ]; |
||
87 | |||
88 | /** |
||
89 | * Whether the model should throw a |
||
90 | * ValidationException if it fails validation. |
||
91 | * |
||
92 | * @var bool |
||
93 | */ |
||
94 | protected $throwValidationExceptions = true; |
||
95 | |||
96 | /** |
||
97 | * Create a new Eloquent model instance. |
||
98 | * |
||
99 | * @param array $attributes |
||
100 | */ |
||
101 | public function __construct(array $attributes = []) |
||
107 | |||
108 | /** |
||
109 | * Get the owning resource model. |
||
110 | * |
||
111 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
112 | */ |
||
113 | public function bookable(): MorphTo |
||
117 | } |
||
118 |