vendredi 21 février 2020

Laravel Yajra DataTable Error if I added record more than 1

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 ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2SMg62T
via IFTTT

1 commentaire:

  1. Your Affiliate Money Printing Machine is ready -

    And making money online using it is as easy as 1 . 2 . 3!

    This is how it works...

    STEP 1. Tell the system which affiliate products the system will advertise
    STEP 2. Add some PUSH button traffic (it LITERALLY takes JUST 2 minutes)
    STEP 3. Watch the system grow your list and sell your affiliate products all on it's own!

    Are you ready to make money automatically???

    You can test-drive the system for yourself risk free...

    RépondreSupprimer