I am trying to store route id of a review (it contains restaurant id) in a variable called restaurant_id in a reviews table. This is the store function:
public function store(Request $request) {
if (! Auth::check()) {
return redirect('/index');
}
$review = new Review;
$review->user_id = auth()->user()->id;
$review->restaurant_id = $request->route('id');
$review->value = $request->input('value');
$review->save();
}
This is the link on the restaurant profile that directs to the review template Add review. This is the action on the form:
{!!Form::open(['action' => ['ReviewsController@store'], 'method'=>'POST', 'enctype'=>'multipart/form-data'])!!}
This is review template:
<html>
{!!Form::open(['action' => ['ReviewsController@store',], 'method'=>'POST', 'enctype'=>'multipart/form-data'])!!}
<div class="form-group">
</div>
{!!Form::close()!!}
</html>
I get the error below when submitting:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'restaurant_id' cannot be null (SQL: insert into reviews (user_id, restaurant_id, value, updated_at, created_at) values (1, ?, kkkkbkb, 2019-07-11 08:39:10, 2019-07-11 08:39:10))
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire