AsgardCms /
Media
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Modules\Media\Support\Traits; |
||
| 4 | |||
| 5 | trait MediaRelation |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Make the Many To Many Morph To Relation |
||
| 9 | * @return object |
||
| 10 | */ |
||
| 11 | public function files() |
||
| 12 | { |
||
| 13 | return $this->morphToMany('Modules\Media\Entities\File', 'imageable', 'media__imageables')->withPivot('zone', 'id')->withTimestamps()->orderBy('order'); |
||
| 14 | } |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Make the Many to Many Morph to Relation with specific zone |
||
| 18 | * @param string $zone |
||
| 19 | * @return object |
||
| 20 | */ |
||
| 21 | public function filesByZone($zone) |
||
| 22 | { |
||
| 23 | return $this->morphToMany('Modules\Media\Entities\File', 'imageable', 'media__imageables') |
||
|
0 ignored issues
–
show
|
|||
| 24 | ->withPivot('zone', 'id') |
||
| 25 | ->wherePivot('zone', '=', $zone) |
||
| 26 | ->withTimestamps() |
||
| 27 | ->orderBy('order'); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |
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
Idableprovides a methodequalsIdthat 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.