protected function prepareDatatablesStructure(
        \Illuminate\Http\Request $request,
        Collection $collection,
        $totalCount,
        $filteredCount
    ) {
        $columns = $this->getColumns();

        $result = [];
        $result['draw'] = $request->input('draw', 0);
        $result['recordsTotal'] = $totalCount;
        $result['recordsFiltered'] = $filteredCount;
        $result['data'] = [];

        foreach ($collection as $instance) {
            $_row = [];

            foreach ($columns->all() as $column) {
                $column->setModel($instance);

                if ($column instanceof Control) {
                    $column->initialize();
                }

                $_row[] = (string) $column;
            }

            $result['data'][] = $_row;
        }

        return $result;
    }
protected function prepareDatatablesStructure(
        \Illuminate\Http\Request $request,
        Collection $collection,
        $totalCount,
        $filteredCount
    ) {
        $columns = $this->getColumns();

        $result = [];
        $result['draw'] = $request->input('draw', 0);
        $result['recordsTotal'] = $totalCount;
        $result['recordsFiltered'] = $filteredCount;
        $result['data'] = [];

        foreach ($collection as $instance) {
            $_row = [];

            foreach ($columns->all() as $column) {
                $column->setModel($instance);

                if ($column instanceof Control) {
                    $column->initialize();
                }

                $_row[] = (string) $column;
            }

            $result['data'][] = $_row;
        }

        return $result;
    }
protected function prepareDatatablesStructure ( \ Illuminate \ Http \ Request $ request , Collection $ collection , $ totalCount , $ filteredCount ) { $ columns = $ this -> getColumns ( ) ; $ result = [ ] ; $ result [ 'draw' ] = $ request -> input ( 'draw' , 0 ) ; $ result [ 'recordsTotal' ] = $ totalCount ; $ result [ 'recordsFiltered' ] = $ filteredCount ; $ result [ 'data' ] = [ ] ; foreach ( $ collection as $ instance ) { $ _row = [ ] ; foreach ( $ columns -> all ( ) as $ column ) { $ column -> setModel ( $ instance ) ; if ( $ column instanceof Control ) { $ column -> initialize ( ) ; } $ _row [ ] = ( string ) $ column ; } $ result [ 'data' ] [ ] = $ _row ; } return $ result ; }
Convert collection to the datatables structure.

@param \Illuminate\Http\Request $request
@param array|Collection $collection
@param int $totalCount
@param int $filteredCount

@return array
Convert collection to the datatables structure .