1 | <?php |
||
8 | trait IsCacheable |
||
9 | { |
||
10 | /** |
||
11 | * Boot the model. |
||
12 | * |
||
13 | * @return void |
||
14 | */ |
||
15 | public static function bootIsCacheable() |
||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | public function getQueryCacheTag(): string |
||
33 | |||
34 | /** |
||
35 | * @return string |
||
36 | */ |
||
37 | public function getDuplicateQueryCacheTag(): string |
||
41 | |||
42 | /** |
||
43 | * Flush the query cache from Redis only for the tag corresponding to the model instance. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function clearQueryCache(): void |
||
51 | |||
52 | /** |
||
53 | * Get a new query builder instance for the connection. |
||
54 | * |
||
55 | * @return Builder |
||
56 | */ |
||
57 | protected function newBaseQueryBuilder(): Builder |
||
91 | } |
||
92 |
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.