Support the ongoing development of Laravel.io →
Requests Input
Last updated 2 years ago.
0

You can also do:

$booking->attach($n);

But for this example in specific I think you're doing it the more organized way. It works clearer when it is a many-to-many relationship (and this one looks like it is) so when you use the attach() function it creates the entry for you in the relationship table

Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

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.