Skip to content
Advertisement

How to Store Multiple Select Values in Laravel 8?

So my problem is that if i try to save only one value like “Location in the layout” of a post it works, but the moment i am saving an array I’m getting something like [“value 1” , “value 2”] in the DB, therefore it cant be read and in the CRUD-Controller there is no data saved when i am editing.everything works perfectly except the value i am getting from the data. I would appreciate any help, methods or alternatives

edit.blade.php

JavaScript

home controller

JavaScript

and view:

JavaScript

post.controller:

JavaScript

Advertisement

Answer

Firstly you should get selected locations in $selectLocations variable and all locations in $allLocations variable for edit.blade.php

In edit.blade.php, you can display like this:-

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