vendredi 21 février 2020

Laravel Yajra DataTable Error if I added more than 1 record

I've create datatatable with Yajra on Laravel, here I want to display data on the table, here is my source code :

$model = SaranaPrasaranaRuang::with('jenis_ruang')->where('dibuat_oleh',$this->user->id)->get();

        $dTable = Datatables()->of($model);
            $dTable = $dTable->addIndexColumn()
            ->editColumn('jenis_ruang',function($ruang){
                $jenis_ruang = $ruang->jenis_ruang->jenis_ruang;
                return $jenis_ruang;
            })
            ->editColumn('nama_ruang',function($data){
                return $data->nama_ruang;
            })
            ->addColumn('standard_prasarana',function($data){
                $btn = '<button class="btn btn-warning detail_prasarana" onclick=detailSarpras(this,'.$data->id_jenis_ruang.')>Lihat Standard Prasarana</button>';
                return $btn;
            })
            ->addColumn('standard_sarana',function($data){
                $btn = '<button class="btn btn-warning detail_sarana" onclick=detailSarpras(this,'.$data->id_jenis_ruang.')>Lihat Standard Sarana</button>';
                return $btn;
            })
            ->addColumn('action',function($data){
                $btn = "";
                $btn .= '<a href="/sarana_prasarana/ruang/edit/'.$data->id.'" class="btn btn-primary"><i class="fa fa-pencil"></i> Edit </a> ';
                $btn .= '<a href="/sarana_prasarana/ruang/delete/'.$data->id.'" class="btn btn-danger" onclick=return confirm("Apakah anda yakin ingin menghapus ?")><i class="fa fa-trash"></i> Hapus </a> ';
                $btn .= '<button class="btn btn-info" onclick=detailRuang('.$data->id.')><i class="fa fa-eye"></i> Detail</button>';
                return $btn;
            })
            ->rawColumns(['standard_prasarana','standard_sarana','action']);

        return $dTable->make(true);

My code above is working fine if my record only 1, but when I added one more record on my table , Datable give me response json like this :

"error": "Exception Message:\n\nUndefined index: "

I've try with eloquent(),query() but still didn't work

Anyone can help me out ?



via Chebli Mohamed

1 commentaire:

  1. Did you realize there's a 12 word phrase you can say to your man... that will trigger deep feelings of love and impulsive attractiveness to you deep within his chest?

    Because deep inside these 12 words is a "secret signal" that triggers a man's impulse to love, admire and guard you with his entire heart...

    12 Words That Fuel A Man's Desire Impulse

    This impulse is so built-in to a man's brain that it will drive him to try better than ever before to make your relationship the best part of both of your lives.

    Matter-of-fact, fueling this mighty impulse is absolutely essential to achieving the best ever relationship with your man that as soon as you send your man one of these "Secret Signals"...

    ...You will immediately notice him open his heart and soul for you in such a way he haven't expressed before and he'll recognize you as the one and only woman in the world who has ever truly understood him.

    RépondreSupprimer