後,我用的引導數據輸入選擇在我的表格的日期。我想在提交表格後保留日期。它已經幾天了,我開始研究,但至今還沒有找到一個解決方案。在我的項目,我使用Laravel 5.4和日期,我使用的是碳。 Laravel的顯示日期字段值表單提交
{{ old('input_date') }}
只是不工作。如果有人能幫我找到解決辦法,那將非常感激。
這是我的控制器代碼:
public function showMisHistory() {
$mises = '';
return view('uploads.mis_history', [
'mises' => $mises,
]);
}
public function showMisHistoryBetweenDates (Request $request) {
$this->validate($request, [
'start_date' => 'required',
'end_date' => 'required',
]);
$mises = Mis::where('uploader_pin', Auth::user()->pin)->whereBetween('date_of_data_type', array($request->start_date, $request->end_date))->get();
// $mises = Mis::where('uploader_pin', Auth::user()->pin)->get();
$totalLoanAmount = collect($mises)->sum('principal_loan_amount');
$totalPremium = collect($mises)->sum('premium');
$row_number = 1;
return view('uploads.mis_history', [
'mises' => $mises,
'totalLoanAmount' => $totalLoanAmount,
'totalPremium' => $totalPremium,
'row_number' => $row_number,
]);
}
這是我使用的形式。
<form action="{{ route('misHistoryBetweenDates') }}" method="POST" class="date-search-form">
{{ csrf_field() }}
<div class="col-md-5">
<div class="form-group">
<label class="col-sm-2 control-label">From</label>
<div class="col-sm-10">
<input type="date" name="start_date" class="form-control" value="{{ old('start_date') }}">
</div>
@if (old('start_date'))
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<span id="helpBlock" class="help-block">{{ old('start_date') }}</span>
</div>
@endif
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label class="col-sm-2 control-label">To</label>
<div class="col-sm-10">
<input type="date" name="end_date" class="form-control" value="{{ old('end_date') }}">
</div>
@if (old('end_date'))
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10">
<span id="helpBlock" class="help-block">{{ old('end_date') }}</span>
</div>
@endif
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<input type="submit" name="submit" class="btn btn-primary">
</div>
</div>
</form>
請出示您的控制器代碼 –
可能是因爲日期的格式... –