Skip to content

Commit 2dd4944

Browse files
committed
Add pivot property
1 parent c1ddd30 commit 2dd4944

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Console/ModelsCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,17 @@ public function getPropertiesFromMethods($model)
637637
);
638638

639639
if (strpos(get_class($relationObj), 'Many') !== false) {
640+
if ($relationObj instanceof BelongsToMany) {
641+
$pivot = get_class($relationObj->newPivot());
642+
if ($pivot != 'Illuminate\Database\Eloquent\Relations\Pivot') {
643+
$this->setProperty(
644+
$relationObj->getPivotAccessor(),
645+
$pivot,
646+
true,
647+
false
648+
);
649+
}
650+
}
640651
//Collection or array of models (because Collection is Arrayable)
641652
$relatedClass = '\\' . get_class($relationObj->getRelated());
642653
$collectionClass = $this->getCollectionClass($relatedClass);

0 commit comments

Comments
 (0)