I have this small project for car posts. I make my post so everything is working properly, but now i need to have multiple selections. So this is my PostsController:
...
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'brand' => 'required',
'model' => 'required',
'age' => 'required',
'cc' => 'required',
'hp' => 'required',
'body' => 'required',
'fuel' => 'required',
'safety' => 'required'
]);
$post = new Post;
$post->title = $request->input('title');
$post->brand = $request->input('brand');
$post->model = $request->input('model');
$post->age = $request->input('age');
$post->cc = $request->input('cc');
$post->hp = $request->input('hp');
$post->body = $request->input('body');
$post->fuel = $request->input('fuel');
$post->safety = $request->input('safety');
$post->save();
return redirect('/home')->with('success', 'Your post is posted!');
}
...
And now this is my createpost.blade.php :
...
<div class="column">
<label for="safety">Safety:</label></br>
<select class="form-control" name="safety">
<option value="" disabled selected>Select your option</option>
<option value="diesel">ABS</option>
<option value="gasoline">ESP</option>
<option value="electric">CHILD LOCK</option>
<option value="electric">AirBAG</option>
</select>
</div>
...
How can i make this select input for multiple selection and all of the selections need to save into my database? I have my Post.php model:
...
class Post extends Model
{
protected $table = 'posts';
protected $primaryKey = 'id';
}
Please help if anybody have solutions for this? Or some tutorials or any help similar!
checkboxinput