0
나는 laravel 5.4와 코드를 가지고 있습니다. 필터 날짜가있는 데이터베이스의 데이터를 표시하고 싶습니다 ... 어떻게 작동합니까? 나를 도와 줄 수 있니? view.blade.php databaseLaravel 5.4에서 필터하기 (작동 원리)
이것은 view.blade.php
<div class="table-responsive">
<table class="table table-striped table-hover table-condensed">
<thead>
<tr>
<th><strong>No</strong></th>
<th><strong>Nama</strong></th>
<th><strong>Alamat</strong></th>
<th><strong>Lokasi</strong></th>
<th><strong>Tanaman</strong></th>
<th><strong>Jumlah Panen</strong></th>
<th><strong>Luas Lahan</strong></th>
</tr>
</thead>
<tbody>
@foreach($hasil as $key => $data)
<tr>
<th>{{$no++}}</th>
<th>{{$data->nama_user}}</th>
<th>{{$data->alamat}}</th>
<th>{{$data->id_lokasi}}</th>
<th>{{$data->nama_tanaman}}</th>
<th>{{$data->jumlah_panen}}</th>
<th>{{$data->luas_lahan_panen}} HA</th>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="col-sm-3">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">Filter</h3>
<p>Pilih Tanggal : {!! Form::input('month', 'published_at', null, ['class' => 'form-control']) !!}</p>
<button name="filter" class="btn btn-primary form-control" id="filter" onclick="filter">Pilih Tanggal</button>
</div>
</div>
</div>
에 내 코드이고이 web.php의 코드 (경로)
Route::get('laporhasil', function() {
$hasil = DB::select("SELECT `tbl_user`.`nama_user`, `tbl_user`.`alamat`, `tbl_lapor_hasil`.`id_lokasi`, `tbl_tanaman`.`nama_tanaman`, `tbl_lapor_hasil`.`luas_lahan_panen`,`tbl_lapor_hasil`.`jumlah_panen`FROM `tbl_lapor_hasil` INNER JOIN `tbl_user` ON `tbl_lapor_hasil`.`id_user` = `tbl_user`.`id_user` INNER JOIN `tbl_tanaman` ON `tbl_lapor_hasil`.`id_tanaman` = `tbl_tanaman`.`id_tanaman`");
$no = 1;
return view('laporhasil', ['hasil' => $hasil], ['no' => $no]);
을})이다;
쿼리 작성기를 사용하면'whereDate' https://laravel.com/docs/5.4/queries라는 메서드가 있습니다. – enriqg9
Eloquent 대신 Query Builder를 사용하는 특별한 이유가 있습니까? – Qazi
@Qazi eloquent는 쿼리를 수행하기 위해 빌더 인스턴스를 사용하며 클로저에서 모델을 사용하지 않습니다. – enriqg9