1 | <?php |
||
12 | abstract class BookableAvailability 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 | 'from', |
||
25 | 'to', |
||
26 | 'is_bookable', |
||
27 | 'priority', |
||
28 | ]; |
||
29 | |||
30 | /** |
||
31 | * {@inheritdoc} |
||
32 | */ |
||
33 | protected $casts = [ |
||
34 | 'bookable_id' => 'integer', |
||
35 | 'bookable_type' => 'string', |
||
36 | 'range' => 'string', |
||
37 | 'from' => 'string', |
||
38 | 'to' => 'string', |
||
39 | 'is_bookable' => 'boolean', |
||
40 | 'priority' => 'integer', |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | protected $observables = [ |
||
47 | 'validating', |
||
48 | 'validated', |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * The default rules that the model will validate against. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $rules = [ |
||
57 | 'bookable_id' => 'required|integer', |
||
58 | 'bookable_type' => 'required|string', |
||
59 | 'range' => 'required|in:datetimes,dates,months,weeks,days,times,sunday,monday,tuesday,wednesday,thursday,friday,saturday', |
||
60 | 'from' => 'required|string|max:150', |
||
61 | 'to' => 'required|string|max:150', |
||
62 | 'is_bookable' => 'required|boolean', |
||
63 | 'priority' => 'nullable|integer', |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * Whether the model should throw a |
||
68 | * ValidationException if it fails validation. |
||
69 | * |
||
70 | * @var bool |
||
71 | */ |
||
72 | protected $throwValidationExceptions = true; |
||
73 | |||
74 | /** |
||
75 | * Create a new Eloquent model instance. |
||
76 | * |
||
77 | * @param array $attributes |
||
78 | */ |
||
79 | public function __construct(array $attributes = []) |
||
85 | |||
86 | /** |
||
87 | * Get the owning resource model. |
||
88 | * |
||
89 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
90 | */ |
||
91 | public function bookable(): MorphTo |
||
95 | } |
||
96 |