Skip to content
Advertisement

How to store array in Laravel?

There are two mysql tables 1.seats (id,number), 2.reservedseats(id,seat_id,sceering_id). I show all the seats of a specific sceering as checkboxes in show.blade:

JavaScript

When I click a checkbox it goes the the seat_id[] array. So I send a hidden input and an array with the seat_ids then I want to store in the reservedseats Mysql table. But in the store controller I have the problem. I’m trying something like:

JavaScript

So it not working but how can I solve that?

Advertisement

Answer

Try this code

JavaScript

Also you can use

JavaScript

That is better way to perform this as it will interact with database for once.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement