0
I have in my view a with Dashboard/index.
This index has a table and a chart that by default, it brings information of the current month (first and last day of the month). I would like to update dynamically through select that has information from the past months.
Route:
Route::get('/dashboard', ['as'=>'dashboard', 'uses'=>'DashboardController@index']);
Route::post('/dashboard', ['as'=>'dashboard.buscapormes', 'uses'=>'DashboardController@buscapormes']);
index.blade.php
<form method="post" action="{{ route('dashboard.buscapormes') }}" >
<select class="mesCorrente" id="mesCorrente" name="buscapormes">
<option selected="selected" name="buscapormes" value="{{ $MesAtual }}">
<?=$Mes."/".date('Y');?>
</option>
<option name="buscapormes" value='{{ $MesMenosUmMes }} '>
<?=$MesMenosUm."/".date('Y');?>
</option>
<option name="buscapormes" value='{{ $MesMenosDoisMeses }}'>
<?=$MesMenosDois."/".date('Y');?>
</option>
<option name="buscapormes" value='{{ $MesMenosTresMeses }}'>
<?=$MesMenosTres."/".date('Y');?>
</option>
</select>
<button type="submit">Enviar</button>
</form>
Dashboardcontroller.php
public function buscapormes(Request $req, $buscapormes)
{
//$registros = $req->all();
//dd($registros);
$title = 'Inffel OnBoard :: Dashboard';
$subtitle = 'Dashboard';
$ClienteID = auth()->user()->cliente_id;
$dataInicio = substr($buscapormes, 0, 10);
$dataFinal = substr($buscapormes, 13, 10);
$dashboard=DB::table('MVE')
->select(DB::raw('DATA, sum(TOTAL) as TOTAL'))
->where('CLIENTE', $ClienteID)
->whereBetween('DATA', [$dataInicio, $dataFinal])
->groupBy('DATA')
->orderBy('DATA')
->get();
return view('dashboard.index', compact('title', 'subtitle', 'dashboard'));
}
Error print https://imgur.com/a/uTHElI
But refreshing gives the same error ? The controller is being called ?
dd($dashboard);
gives the result you expect ?– Isac
Puts your answer that csrf is missing in the form.
– fabricio_wm