I have 15 Checkbox at my admin panel so only website admin can select or cancel them.
I need to save checkbox's that checked at my table like this:
Name: car,food,game,...
HTML:
<div class="form-group">
<label for="art" class="checkbox-inline">
Art
</label>
<label for="artitecture" class="checkbox-inline">
Artitecture
</label>
<label for="business" class="checkbox-inline">
Business
</label>
...
<div class="form-group">
</div>
My Controller Store Function :
public function store(Request $request)
{
$add_hobby=new Hobbies;
$add_hobby->name=$request->all();
$add_hobby->save();
return redirect()->back();
}
Also try this but only save the last one :
public function store(Request $request)
{
$add_hobby=new Hobbies;
$add_hobby->name=$request->input('car');
$add_hobby->name=$request->input('food');
...
$add_hobby->name=$request->input('fashion');
$add_hobby->save();
return redirect()->back();
}
I tried this too but I got Error :
public function store(Request $request)
{
$request->merge([
'name' => implode(',', (array) $request->input('game')),
'name' => implode(',', (array) $request->input('food')),
...
'name' => implode(',', (array) $request->input('fashion')),
]);
$add_hobby=new Hobbies;
$add_hobby->name=$request->input()->all();
$add_hobby->save();
return redirect()->back();
}
Anyone can help?
Of course is not necessary save at one column but also i don't know another way to save them
Aucun commentaire:
Enregistrer un commentaire