Skip to content

Commit

Permalink
Improve eloquent attach parameter consistency (#54225)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpl authored Jan 17, 2025
1 parent 9ee1432 commit 8961a43
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,21 +260,21 @@ protected function updateExistingPivotUsingCustomClass($id, array $attributes, $
/**
* Attach a model to the parent.
*
* @param mixed $id
* @param mixed $ids
* @param array $attributes
* @param bool $touch
* @return void
*/
public function attach($id, array $attributes = [], $touch = true)
public function attach($ids, array $attributes = [], $touch = true)
{
if ($this->using) {
$this->attachUsingCustomClass($id, $attributes);
$this->attachUsingCustomClass($ids, $attributes);
} else {
// Here we will insert the attachment records into the pivot table. Once we have
// inserted the records, we will touch the relationships if necessary and the
// function will return. We can parse the IDs before inserting the records.
$this->newPivotStatement()->insert($this->formatAttachRecords(
$this->parseIds($id), $attributes
$this->parseIds($ids), $attributes
));
}

Expand All @@ -286,14 +286,14 @@ public function attach($id, array $attributes = [], $touch = true)
/**
* Attach a model to the parent using a custom class.
*
* @param mixed $id
* @param mixed $ids
* @param array $attributes
* @return void
*/
protected function attachUsingCustomClass($id, array $attributes)
protected function attachUsingCustomClass($ids, array $attributes)
{
$records = $this->formatAttachRecords(
$this->parseIds($id), $attributes
$this->parseIds($ids), $attributes
);

foreach ($records as $record) {
Expand Down

0 comments on commit 8961a43

Please sign in to comment.