Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

ErikEklund said: return View::make('edititem')->with(compact('item', 'groups'));

You used

compact('item', 'groups')

but I don't see where is the $groups variable defined.

Last updated 1 year ago.
0

Stolz said:

You used

compact('item', 'groups')

but I don't see where is the $groups variable defined.

It was just an example, and the $groups variable doesn't matter to the question (declared previously, outside example code). My question was if it is intended behaviour that sync() doesn't update the object you run it on.

Last updated 1 year ago.
0

Yes, it's intended behaviour. Sync is only for update the pivot table.

May be what you are looking for is the method $item->push();

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ErikEklund erikeklund Joined 14 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.