Skip to content

Commit 850182e

Browse files
authored
allow to call BelongsToMany::firstOrNew/Create without parameters (#37791)
1 parent cc84229 commit 850182e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ public function findOrNew($id, $columns = ['*'])
596596
* @param array $attributes
597597
* @return \Illuminate\Database\Eloquent\Model
598598
*/
599-
public function firstOrNew(array $attributes)
599+
public function firstOrNew(array $attributes = [])
600600
{
601601
if (is_null($instance = $this->related->where($attributes)->first())) {
602602
$instance = $this->related->newInstance($attributes);
@@ -614,7 +614,7 @@ public function firstOrNew(array $attributes)
614614
* @param bool $touch
615615
* @return \Illuminate\Database\Eloquent\Model
616616
*/
617-
public function firstOrCreate(array $attributes, array $values = [], array $joining = [], $touch = true)
617+
public function firstOrCreate(array $attributes = [], array $values = [], array $joining = [], $touch = true)
618618
{
619619
if (is_null($instance = $this->related->where($attributes)->first())) {
620620
$instance = $this->create($attributes + $values, $joining, $touch);

0 commit comments

Comments
 (0)