1 | <?php |
||
5 | trait LaraCedTrait |
||
6 | { |
||
7 | public static function bootLaraCedTrait() |
||
11 | |||
12 | /** |
||
13 | * Has the model loaded the SoftDeletes trait. |
||
14 | * |
||
15 | * @return bool |
||
16 | */ |
||
17 | public static function isUseSoftDeletes() |
||
26 | |||
27 | /** |
||
28 | * Get user model. |
||
29 | */ |
||
30 | public function getUserModel() |
||
36 | |||
37 | /** |
||
38 | * Get the name of the "creator" column. |
||
39 | * |
||
40 | * @return string |
||
41 | */ |
||
42 | public function getCreatorColumn() |
||
46 | |||
47 | /** |
||
48 | * Get the name of the "editor" column. |
||
49 | * |
||
50 | * @return string |
||
51 | */ |
||
52 | public function getEditorColumn() |
||
56 | |||
57 | /** |
||
58 | * Get the name of the "destroyer" column. |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | public function getDestroyerColumn() |
||
66 | |||
67 | /** |
||
68 | * Creator, relation with user model. |
||
69 | */ |
||
70 | public function creator() |
||
74 | |||
75 | /** |
||
76 | * Editor, relation with user model. |
||
77 | */ |
||
78 | public function editor() |
||
82 | |||
83 | /** |
||
84 | * Destroyer, relation with user model. |
||
85 | */ |
||
86 | public function destroyer() |
||
90 | } |
||
91 |
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.