jeudi 31 octobre 2019

can't retrieve the data from database in laravel

I have the controller with function

public function caritiket(Request $request){
    $tgl=($request->tgl);
    $kota1 = ($request->kota1);
    $kota2 = ($request->kota2);
    $jumlah = (int)$request->jml_p;

    // $cek = DB::table('tb_bis_wp')->where('tanggal',$request->tgl)->where('kota1',$request->kota1)->where('kota2',$request->kota2)->count();
    // if ($cek > 0) {
        $cek1 = DB::table('tb_bis_wp')->where('tanggal',$request->tgl)->where('kota1',$request->kota1)->where('kota2',$request->kota2)->get();
        foreach ($cek1 as $cek1) {
            $a=$cek1->tanggal;
            $b=$cek1->kota1;
            $c=$cek1->kota2;
        }
        return redirect('/tampil/daftartiket////');}

the input from view is already have the same name as in the function caritiket(Request $request), after that the route link to function daftartiket() this is the function daftartiket

public function daftartiket($a,$b,$c,$jumlah){
        $jml= $jumlah;
$data = DB::table('tb_bis_wp')->where('tanggal',$a)->where('kota1',$b)->where('kota2',$c)->get();


                return view('member/daftar_tiket',['data'=>$data]);
    }

in the view i have script like this

 <table class="table table-bordered tabel table-striped">
                <thead class="thead-dark text-center">
                    <tr>
                        <th scope="col">Kode Rute</th>
                        <th scope="col">Waktu</th>
                        <th scope="col">Rute</th>
                        <th scope="col">Kelas</th>
                        <th scope="col">Harga</th>
                        <th scope="col">Sisa Kursi</th>
                        <th scope="col">Option</th>
                    </tr>
                </thead>
                <tbody class="text-center">
                @foreach($data as $z)
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        <td>
                            <a href="/tampil/#/" class="btn btn-primary ">Pesan</a>
                        </td>
                        </tr>
                    @endforeach
                </tbody>
              </table>

it can direct to the view, but the data can't out, can somone help me?




Aucun commentaire:

Enregistrer un commentaire