So basically I got two tables, GameIDs table with client_game_id (int) column and Settings table with subscribed (integer[]) array type column. Got multiple select form that lists all game ids from game_ids and got to store them in the array type column. The tables got no relation.
<div class="form-group">
<label for="games">Games</label><br>
<select name="games" id="games" class="selectpicker" multiple data-selected-text-format="count > 3" title="Choose games...">
@foreach($clientgameids as $clientgameid)
<option value="{{ $clientgameid->client_game_id }}">{{ $clientgameid->client_game_name }}</option>
@endforeach
</select>
</div>
How do I prefix every item in the collection with '{}' since laravel does not support array[] columns and store it in the table ?
use name="games[]" instead of name="games" in view
<select name="games[]" id="games" class="selectpicker" multiple data-selected-text-format="count > 3" title="Choose games...">
write like this way in view
{!!Form::open(array('route'=>'insert','id'=>'frmsave','method'=>'post'))!!}
<div class="form-group">
<label for="games">Games</label><br>
<select name="games[]" id="games" class="selectpicker" multiple data-selected-text-format="count > 3" title="Choose games...">
@foreach($clientgameids as $clientgameid)
<option value="{{ $clientgameid->client_game_id }}">{{ $clientgameid->client_game_name }}</option>
@endforeach
</select>
</div>
{!!Form::hidden('_token',csrf_token())!!}
{!!Form::close()!!}
in route.php
Route::post('/insert',array('as'=>'insert','uses'=>'yourcontrollername@insert'));
then in controller write
public function insert(){
$gm=Input::get('games');
var_dump($gm);
foreach ($pricepr as $key => $v) {
$data=array(
'table_coln_name' => $gm,
);
yourmodel::insert($data);
}//foreach end
}