I have in my view the with dashboard / index.
This index has a table and a graph which, by default, contains information for the current month (first and last day of the month). I would like to dynamically update through select which has information from the last few 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 link