Wednesday, April 12, 2017

Filter on Laravel 5.4 (How it's work?)

i have code with laravel 5.4 i wanna show data from database with filter date... how it's work? can help me? view.blade.php database

and this's my code in 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></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                        <th></th>
                                        <th> 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>

and this's the code from web.php (route)

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]);

});



via Yosua Simanjuntak

Advertisement