Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

Was just looking for the same thing ;)

Try $this->load('roles') in your function after attaching the new role. This will refresh the roles relationship. Not sure if this is best practice, though, but it works...

Last updated 2 years ago.
0

It worked for me too, it would be great to know if load() makes another query to the database, I also think it should do that by default.

Thanks Shineability

0

Thanks, Shineability, that helped... You would indeed expect the relationships to be loaded by default after attaching..

0

Thanks shineability that worked for me.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

brucek2 brucek2 Joined 16 Mar 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.