1 | <?php |
||
10 | trait HasTranslatableRelationships |
||
11 | { |
||
12 | use HasRelationships; |
||
13 | |||
14 | /** |
||
15 | * Define a many-to-many relationship. |
||
16 | * |
||
17 | * @param string $related |
||
18 | * @param string|null $table |
||
19 | * @param string|null $foreignPivotKey |
||
20 | * @param string|null $relatedPivotKey |
||
21 | * @param string|null $parentKey |
||
22 | * @param string|null $relatedKey |
||
23 | * @param string|null $relation |
||
24 | * @return \BBSLab\NovaTranslation\Models\Relations\BelongsToMany |
||
25 | */ |
||
26 | public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
||
58 | |||
59 | /** |
||
60 | * Instantiate a new BelongsToMany relationship. |
||
61 | * |
||
62 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
63 | * @param \Illuminate\Database\Eloquent\Model $parent |
||
64 | * @param string $table |
||
65 | * @param string $foreignPivotKey |
||
66 | * @param string $relatedPivotKey |
||
67 | * @param string $parentKey |
||
68 | * @param string $relatedKey |
||
69 | * @param string|null $relationName |
||
70 | * @return \BBSLab\NovaTranslation\Models\Relations\BelongsToMany |
||
71 | */ |
||
72 | protected function newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey, |
||
77 | } |
||
78 |
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.