1 | <?php namespace Cviebrock\EloquentLoggable; |
||
7 | trait Loggable |
||
8 | { |
||
9 | |||
10 | /** |
||
11 | * Register events that intercept when model is being saved. |
||
12 | */ |
||
13 | public static function bootLoggable() |
||
17 | |||
18 | /** |
||
19 | * Get a list of attributes that are loggable. |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | public function getLoggableAttributes(): array |
||
27 | |||
28 | /** |
||
29 | * Get a list of attributes that are unloggable. |
||
30 | * |
||
31 | * @return array |
||
32 | */ |
||
33 | public function getUnloggableAttributes(): array |
||
37 | |||
38 | /** |
||
39 | * Relation to changes. |
||
40 | * |
||
41 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
42 | */ |
||
43 | public function changes(): MorphMany |
||
48 | } |
||
49 |
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.