From f5e66ed25f2705a7a1ab47f15d63474273c9e5ae Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 23 Jun 2021 18:46:57 +0200 Subject: [PATCH] allow to call BelongsToMany::firstOrNew/Create without parameters --- src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php index a5166fb4910c..58c64ea5c51a 100755 --- a/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php +++ b/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php @@ -596,7 +596,7 @@ public function findOrNew($id, $columns = ['*']) * @param array $attributes * @return \Illuminate\Database\Eloquent\Model */ - public function firstOrNew(array $attributes) + public function firstOrNew(array $attributes = []) { if (is_null($instance = $this->related->where($attributes)->first())) { $instance = $this->related->newInstance($attributes); @@ -614,7 +614,7 @@ public function firstOrNew(array $attributes) * @param bool $touch * @return \Illuminate\Database\Eloquent\Model */ - public function firstOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true) + public function firstOrCreate(array $attributes = [], array $values = [], array $joining = [], $touch = true) { if (is_null($instance = $this->related->where($attributes)->first())) { $instance = $this->create($attributes + $values, $joining, $touch);