I want to send data from a Controller to an other one. From Client Crud to Reservation Crud. With this form i want send to booking method in ReservationController to associate a room with the client.
<form action="{{Route('reservation.booking', $room->id, $client->id)}}" method="POST">
@csrf
@method('get')
<select class="roomname" name="roomname">
<option selected>Elige habitacion</option>
<option value="{{$rooms[0]->id}}">ESTANÇA DEL PUIGRACIÓS</option>
<option value="{{$rooms[1]->id}}">ESTANÇA DE SANT CRISTÒFOL</option>
<option value="{{$rooms[2]->id}}">ESTANÇA (DÚPLEX) DEL ROCACENTELLA</option>
</select>
<input type="submit" value="Reservar habitación" class = "btn btn-primary">
</form>
public function booking(Room $room, Client $client)
{
//dd($client);
$room->client()->associate($client);
$room->save();
return redirect(route('reservation.create'));
}
The route definition:
Route::get('/reservation/{reservation}/booking','ReservationController@booking')
->name('reservation.booking');
And I got this message:
SQLSTATE[HY000]: General error: 1364 Field 'name' doesn't have a default value (SQL: insert into
rooms(client_id,updated_at,created_at) values (?, 2020-05-10 16:21:19, 2020-05-10 16:21:19))
