Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve eloquent attach parameter consistency #54225

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading