Support the ongoing development of Laravel.io →
posted 11 years ago
Eloquent

Hi, I'm trying to associate Users with workgroups... but I keep getting error call to undefined method associate() . This are my two models and controller with store method

http://laravel.io/bin/DVon

User can be in many work groups. Work group can contain many users.

Last updated 2 years ago.
0

Anyone?

Last updated 2 years ago.
0

You have 2 options to do this:

User::find($user->id)->workGroups()->save($workGroup);

or

$workGroup->groupUsers()->associate($user);
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

RokSiEu roksieu Joined 31 Jan 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.

© 2025 Laravel.io - All rights reserved.