1 | <?php |
||
12 | trait Bookable |
||
13 | { |
||
14 | use BookingScopes; |
||
15 | |||
16 | /** |
||
17 | * Register a saved model event with the dispatcher. |
||
18 | * |
||
19 | * @param \Closure|string $callback |
||
20 | * |
||
21 | * @return void |
||
22 | */ |
||
23 | abstract public static function saved($callback); |
||
24 | |||
25 | /** |
||
26 | * Register a deleted model event with the dispatcher. |
||
27 | * |
||
28 | * @param \Closure|string $callback |
||
29 | * |
||
30 | * @return void |
||
31 | */ |
||
32 | abstract public static function deleted($callback); |
||
33 | |||
34 | /** |
||
35 | * Define a polymorphic one-to-many relationship. |
||
36 | * |
||
37 | * @param string $related |
||
38 | * @param string $name |
||
39 | * @param string $type |
||
|
|||
40 | * @param string $id |
||
41 | * @param string $localKey |
||
42 | * |
||
43 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
44 | */ |
||
45 | abstract public function morphMany($related, $name, $type = null, $id = null, $localKey = null); |
||
46 | |||
47 | /** |
||
48 | * Get the booking model name. |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | abstract public static function getBookingModel(): string; |
||
53 | |||
54 | /** |
||
55 | * Get the rate model name. |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | abstract public static function getRateModel(): string; |
||
60 | |||
61 | /** |
||
62 | * Get the availability model name. |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | abstract public static function getAvailabilityModel(): string; |
||
67 | |||
68 | /** |
||
69 | * Boot the Bookable trait for the model. |
||
70 | * |
||
71 | * @return void |
||
72 | */ |
||
73 | public static function bootBookable() |
||
79 | |||
80 | /** |
||
81 | * Attach the given bookings to the model. |
||
82 | * |
||
83 | * @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids |
||
84 | * @param mixed $bookings |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | public function setBookingsAttribute($bookings): void |
||
94 | |||
95 | /** |
||
96 | * Attach the given rates to the model. |
||
97 | * |
||
98 | * @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids |
||
99 | * @param mixed $rates |
||
100 | * |
||
101 | * @return void |
||
102 | */ |
||
103 | public function setRatesAttribute($rates): void |
||
109 | |||
110 | /** |
||
111 | * Attach the given availabilities to the model. |
||
112 | * |
||
113 | * @param \Illuminate\Database\Eloquent\Collection|\Illuminate\Support\Collection|array $ids |
||
114 | * @param mixed $availabilities |
||
115 | * |
||
116 | * @return void |
||
117 | */ |
||
118 | public function setAvailabilitiesAttribute($availabilities): void |
||
124 | |||
125 | /** |
||
126 | * The resource may have many bookings. |
||
127 | * |
||
128 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
129 | */ |
||
130 | public function bookings(): MorphMany |
||
131 | { |
||
132 | return $this->morphMany(static::getBookingModel(), 'bookable', 'bookable_type', 'bookable_id'); |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Get bookings by the given customer. |
||
137 | * |
||
138 | * @param \Illuminate\Database\Eloquent\Model $customer |
||
139 | * |
||
140 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
141 | */ |
||
142 | public function bookingsBy(Model $customer): MorphMany |
||
146 | |||
147 | /** |
||
148 | * The resource may have many availabilities. |
||
149 | * |
||
150 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
151 | */ |
||
152 | public function availabilities(): MorphMany |
||
156 | |||
157 | /** |
||
158 | * The resource may have many rates. |
||
159 | * |
||
160 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
161 | */ |
||
162 | public function rates(): MorphMany |
||
166 | |||
167 | /** |
||
168 | * Book the model for the given customer at the given dates with the given price. |
||
169 | * |
||
170 | * @param \Illuminate\Database\Eloquent\Model $customer |
||
171 | * @param string $startsAt |
||
172 | * @param string $endsAt |
||
173 | * |
||
174 | * @return \Rinvex\Bookings\Models\BookableBooking |
||
175 | */ |
||
176 | public function newBooking(Model $customer, string $startsAt, string $endsAt): BookableBooking |
||
187 | } |
||
188 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.