Skip to content

Commit 641d087

Browse files
committed
add get pivot class method
1 parent 4777740 commit 641d087

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Database\Eloquent\Model;
77
use Illuminate\Database\Eloquent\Builder;
88
use Illuminate\Database\Eloquent\Collection;
9+
use Illuminate\Database\Eloquent\Relations\Pivot;
910
use Illuminate\Database\Eloquent\ModelNotFoundException;
1011

1112
class BelongsToMany extends Relation
@@ -266,6 +267,16 @@ protected function buildDictionary(Collection $results)
266267
return $dictionary;
267268
}
268269

270+
/**
271+
* Get the class being used for pivot models.
272+
*
273+
* @return string
274+
*/
275+
public function getPivotClass()
276+
{
277+
return $this->using ?? Pivot::class;
278+
}
279+
269280
/**
270281
* Specify the custom pivot model to use for the relationship.
271282
*

0 commit comments

Comments
 (0)