when i click the success button i have to change 'confirmação' value to 1.
Is that possible? I have to create a form to do this?
Schema::create('visitas', function (Blueprint $table) {
$table->increments('id');
$table->date('data');
$table->time('hora');
$table->boolean('confirmacao')->default(0);
$table->integer('imovel_id');
$table->integer('client_id');
$table->timestamps();
Yes you can do it with or without a form. But better with form
<form method="post" action="/visitas">
<input type="hidden" name="visitaID" value="$visita->id"/>
<button class="btn btn-lg btn-success" type="submit">
Confirmar Visita
</button>
</form>
Define the route
Route::post('visitas', 'VistaController@update');
Write the function the controller
public function update(Request $request)
{
$visita = Visita::find($request->visitaID);
$visita->confirmacao = 1;
$visita->update();
return redirect()->back()->with('message', 'visita updated');
}
That's one way of doing it.
It can be done. You would have to run the query by passing the id to a method in your controller for it to update the current data you are confirming.
Yes, It is possible to update database value by clicking on button. You can do this by using ajax request and pass primary key on ajax request data then update "confirmacao" field only for specific primary key record.