yajra / laravel-datatables

jQuery DataTables API for Laravel
https://yajrabox.com/docs/laravel-datatables
MIT License
4.75k stars 859 forks source link

Error: Call to a member function getQuery() on array datatable #1589

Closed azzario closed 11 months ago

azzario commented 6 years ago

i have some problem when i use yajra/datatables package in my laravel 5.3 the errors say :

Call to a member function getQuery() on array

this is my script :

ProdukController@listData

public function listData()
{
    $produk = Produk::join('kategori', 'kategori.id_kategori', '=', 'produk.id_kategori')
                        ->orderBy('produk.id_kategori', 'desc')
                        ->get();
    $no     = 0;
    $data   = array();
    foreach($produk as $list) {
        $no ++;
        $row    = [];
        $row[]  = $no;
        $row[]  = $list->nama_produk;
        $row[]  = $list->nama_kategori;
        $row[]  = $list->harga_jual;
        $row[]  = "<a onclick='editForm(".$list->id_produk.")' class='btn btn-primary'>Edit</a>
                   <a onclick='deleteData(".$list->id_produk.")' class='btn btn-danger'>Hapus</a>";
        $data[]   = $row;
    }
    return Datatables::of($data)->escapeColumns([])->make(true);
}

index.blade.php

@section('script')
<script>
    $(function() {
        $('.table').DataTable({
            "processing" : true,
            "serverside" : true,
            "ajax" : {
                "url"  : "{{ route('dataproduk') }}"
            }
        });
    });
</script>
@endsection

web.php


Route::get('dataproduk', 'ProdukController@listData')-
>name('dataproduk');
krismawan4 commented 6 years ago

same for me

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 11 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale.