1 | <?php |
||
12 | trait HasPivotTable |
||
13 | { |
||
14 | use HasPivotForeignKey; |
||
15 | use HasPivotPrimaryKey; |
||
16 | |||
17 | /** |
||
18 | * @param $params |
||
19 | */ |
||
20 | public function addPivotParams($params) |
||
25 | |||
26 | /** |
||
27 | * @return Connection |
||
28 | */ |
||
29 | 1 | public function getDB() |
|
33 | |||
34 | /** @noinspection PhpMissingParentCallCommonInspection |
||
35 | * @return string |
||
36 | */ |
||
37 | 2 | public function generateTable() |
|
41 | |||
42 | /** |
||
43 | * Builds the name of a has-and-belongs-to-many association table |
||
44 | * @return string |
||
45 | */ |
||
46 | 1 | public function generatePivotTable() |
|
56 | |||
57 | /** |
||
58 | * @param SelectQuery $query |
||
59 | */ |
||
60 | 1 | protected function hydrateQueryWithPivotConstraints($query) |
|
66 | } |
||
67 |
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.