1 | <?php |
||
8 | trait AutoCache |
||
9 | { |
||
10 | /** |
||
11 | * Set the cache expiry time. |
||
12 | * |
||
13 | * @var int |
||
14 | */ |
||
15 | public $cacheExpiry = 1440; |
||
16 | |||
17 | /** |
||
18 | * Create a new Eloquent query builder for the model. |
||
19 | * |
||
20 | * @param \Illuminate\Database\Query\Builder $query |
||
21 | * @return \PulkitJalan\Cacheable\Eloquent\Builder|static |
||
22 | */ |
||
23 | public function newEloquentBuilder($query) |
||
27 | |||
28 | /** |
||
29 | * Refresh the current models cache. |
||
30 | * |
||
31 | * @return $this |
||
32 | */ |
||
33 | public function refresh() |
||
39 | } |
||
40 |
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.