1
路線如何查看數據:根據日期範圍內使用laravel和mysql
Route::post('dategraph','Chatbot\[email protected]');
控制器:
public function dategraph(Request $request)
{
$dategraph = DiraStatistics::all()->whereBetween('date_access', [$from, $to])->get();
$dates = $dategraph('date_access');
return view('AltHr.Chatbot.graph', compact('dates'));
}
查看:
<form id="form-project" role="form" action="{{action('AltHr\Chatbot\[email protected]')}}" autocomplete="off" method="POST">
{{csrf_field()}}
<!-- <canvas id="myChart" width="150" height="50"></canvas> -->
<div class="form-group-attached">
<div class="row">
<div class="col-lg-6">
<div class="form-group form-group-default required" >
<label>From</label>
<input type="date" class="form-control" name="from" required>
</div>
</div>
<div class="col-lg-6">
<div class="form-group form-group-default required" >
<label>To</label>
<input type="date" class="form-control" name="to">
</div>
</div>
</div>
</div>
<button class="btn alt-btn-black btn-xs alt-btn pull-right" type="submit">Next</button>
</form>
嗨,大家好,讓我嘗試查看所選日期的數據作爲編寫的代碼。但即時通訊出現錯誤。我寫錯了嗎?或者我錯過了什麼?
轉向一個扁平陣列'[$從,$至]'不能看到在代碼的這些值。 –
@DanyalSandeelo對不起,你的意思是? – anon
$ from和$ to的值,你需要從$ request中獲取它們作爲'$ request-> input()['from']' –