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

Don't you know how to do an ajax lookup / response? Auto filling one or more fields Using ajax is ajax 101. Use jquery ajax.

Last updated 9 years ago.
0

i'm referring purely to updating a data array to the lookup table, not the front end.

Last updated 9 years ago.
0

before

book_id, language_id
1,          1
1,           2

after

book_id, language_id
1,          2
1,          3
1,          4

one row is deleted (1,1), one remains the same (1,2), two rows are added. I'm asking if Eloquent will do that automatically somehow

Last updated 9 years ago.
0

Sorry mis-understood question.

0
Solution

@jmp909, you are looking for sync() method:

$book->languages()->sync( $array_of_language_ids );

See Inserting related models section of docs on Eloquent.

0

great thanks. I did see that somewhere but wasn't quite sure if it was what I needed

will try it out

regards J

0

Sign in to participate in this thread!

Eventy

Your banner here too?

jmp909 jmp909 Joined 29 Jan 2015

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.