I have a page where user can vote which gaming platform (for example) is the best. In MySQL I have a table of these items. I want to update 'count' field and set it to +1 every time when specified item is checked.
After form is submitted I get an array of selected items:
0 => "XBOX"
1 => "PS4"
2 => "PC"
$value = Input::get('platform'); //this produces presented array
$test = Platform::where('name', 'LIKE', implode(" ", $value))->get();
I think you should use
whereIn instead of
$test = Platform::whereIn('name', $value)->get();
You can do this by DB::raw():
DB::table('Platforms') ->whereIn('name', $value) ->update([ 'count' => DB::raw('count + 1') ]);