1 | <?php |
||
5 | trait HasPushSubscriptions |
||
6 | { |
||
7 | /** |
||
8 | * Get all of the subscriptions. |
||
9 | * |
||
10 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
11 | */ |
||
12 | 2 | public function pushSubscriptions() |
|
16 | |||
17 | /** |
||
18 | * Update (or create) subscription. |
||
19 | * |
||
20 | * @param string $endpoint |
||
21 | * @param string $endpoint_key |
||
22 | * @param string|null $key |
||
23 | * @param string|null $token |
||
24 | * @param string|null $contentEncoding |
||
25 | * @return \NotificationChannels\WebPush\PushSubscription |
||
26 | */ |
||
27 | 2 | public function updatePushSubscription($endpoint, $key = null, $token = null, $contentEncoding = null) |
|
52 | |||
53 | /** |
||
54 | * Determine if the model owns the given subscription. |
||
55 | * |
||
56 | * @param \NotificationChannels\WebPush\PushSubscription $subscription |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function ownsPushSubscription($subscription) |
||
64 | |||
65 | /** |
||
66 | * Delete subscription by endpoint. |
||
67 | * |
||
68 | * @param string $endpoint |
||
69 | * @return void |
||
70 | */ |
||
71 | public function deletePushSubscription($endpoint) |
||
77 | |||
78 | /** |
||
79 | * Get all of the subscriptions. |
||
80 | * |
||
81 | * @return \Illuminate\Database\Eloquent\Collection |
||
82 | */ |
||
83 | public function routeNotificationForWebPush() |
||
87 | } |
||
88 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.