Skip to content

Commit

Permalink
fix collection wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Oct 7, 2020
1 parent 4a25449 commit 9245807
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Illuminate\Database\Eloquent\Factories;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;

class BelongsToManyRelationship
{
Expand Down Expand Up @@ -50,7 +51,7 @@ public function __construct(Factory $factory, $pivot, $relationship)
*/
public function createFor(Model $model)
{
$this->factory->create([], $model)->each(function ($attachable) use ($model) {
Collection::wrap($this->factory->create([], $model))->each(function ($attachable) use ($model) {
$model->{$this->relationship}()->attach(
$attachable,
is_callable($this->pivot) ? call_user_func($this->pivot, $model) : $this->pivot
Expand Down

0 comments on commit 9245807

Please sign in to comment.