Skip to content

[5.6] Add tests for updating existing pivot + add option for passing model#23535

Merged
taylorotwell merged 1 commit into
laravel:5.6from
bobbybouwmann:feature/update-pivot-using-model
Mar 14, 2018
Merged

[5.6] Add tests for updating existing pivot + add option for passing model#23535
taylorotwell merged 1 commit into
laravel:5.6from
bobbybouwmann:feature/update-pivot-using-model

Conversation

@bobbybouwmann
Copy link
Copy Markdown
Contributor

Added the parseId method to the InteractsWithPivotTable trait. This way we can now use models to update existing pivot values. For example

// Before (which still works as well)
$post->tags()->updateExistingPivot($tag->id, ['key' => 'value']);

// After
$post->tags()->updateExistingPivot($tag, ['key' => 'value']);

In addition to that I also added the missings tests for this method ;)

If for some reason you decide not to take the model part, you can at least add the tests 👍

@GrahamCampbell GrahamCampbell changed the title Add tests for updating existing pivot + add option for passing model [5.6] Add tests for updating existing pivot + add option for passing model Mar 14, 2018
@taylorotwell taylorotwell merged commit a05ee88 into laravel:5.6 Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants