Sunday, April 2, 2017

FatalThrowableError in ProiodaController.php line 32: Call to undefined method App\DataTables\ProiodaDataTable::render()

Hi i am getting an error with laravel 5.4 i am using infyom/laravel-generator package and when i use the php artisan infyom:scaffold ModelName --datatables=true when i go to the view im getting the error.

FatalThrowableError in ProiodaController.php line 32: Call to undefined method App\DataTables\ProiodaDataTable::render()

This is my controller ProiodaController.php

<?php 
namespace App\Http\Controllers;
use App\DataTables\ProiodaDataTable;
use App\Http\Requests;
use App\Http\Requests\CreateProiodaRequest;
use App\Http\Requests\UpdateProiodaRequest;
use App\Repositories\ProiodaRepository;
use Flash;
use App\Http\Controllers\AppBaseController;
use Response;

class ProiodaController extends AppBaseController
{
/** @var  ProiodaRepository */
private $proiodaRepository;

public function __construct(ProiodaRepository $proiodaRepo)
{
    $this->proiodaRepository = $proiodaRepo;
}

/**
 * Display a listing of the Proioda.
 *
 * @param ProiodaDataTable $proiodaDataTable
 * @return Response
 */
public function index(ProiodaDataTable $proiodaDataTable)
{
    return $proiodaDataTable->render('proiodas.index');
}

/**
 * Show the form for creating a new Proioda.
 *
 * @return Response
 */
public function create()
{
    return view('proiodas.create');
}

/**
 * Store a newly created Proioda in storage.
 *
 * @param CreateProiodaRequest $request
 *
 * @return Response
 */
public function store(CreateProiodaRequest $request)
{
    $input = $request->all();

    $proioda = $this->proiodaRepository->create($input);

    Flash::success('Proioda saved successfully.');

    return redirect(route('proiodas.index'));
}

/**
 * Display the specified Proioda.
 *
 * @param  int $id
 *
 * @return Response
 */
public function show($id)
{
    $proioda = $this->proiodaRepository->findWithoutFail($id);

    if (empty($proioda)) {
        Flash::error('Proioda not found');

        return redirect(route('proiodas.index'));
    }

    return view('proiodas.show')->with('proioda', $proioda);
}

/**
 * Show the form for editing the specified Proioda.
 *
 * @param  int $id
 *
 * @return Response
 */
public function edit($id)
{
    $proioda = $this->proiodaRepository->findWithoutFail($id);

    if (empty($proioda)) {
        Flash::error('Proioda not found');

        return redirect(route('proiodas.index'));
    }

    return view('proiodas.edit')->with('proioda', $proioda);
}

/**
 * Update the specified Proioda in storage.
 *
 * @param  int              $id
 * @param UpdateProiodaRequest $request
 *
 * @return Response
 */
public function update($id, UpdateProiodaRequest $request)
{
    $proioda = $this->proiodaRepository->findWithoutFail($id);

    if (empty($proioda)) {
        Flash::error('Proioda not found');

        return redirect(route('proiodas.index'));
    }

    $proioda = $this->proiodaRepository->update($request->all(), $id);

    Flash::success('Proioda updated successfully.');

    return redirect(route('proiodas.index'));
}

/**
 * Remove the specified Proioda from storage.
 *
 * @param  int $id
 *
 * @return Response
 */
public function destroy($id)
{
    $proioda = $this->proiodaRepository->findWithoutFail($id);

    if (empty($proioda)) {
        Flash::error('Proioda not found');

        return redirect(route('proiodas.index'));
    }

    $this->proiodaRepository->delete($id);

    Flash::success('Proioda deleted successfully.');

    return redirect(route('proiodas.index'));
}
}

This is ProiodaDataTable.php

<?php

namespace App\DataTables;

use App\Models\Proioda;
use Form;
use Yajra\Datatables\Facades\Datatables;
use Illuminate\Support\Facades\View;

class ProiodaDataTable extends Datatables
{

/**
 * @return \Illuminate\Http\JsonResponse
 */
public function ajax()
{
    return $this->datatables
        ->eloquent($this->query())
        ->addColumn('action', 'proiodas.datatables_actions')
        ->make(true);
}

/**
 * Get the query object to be processed by datatables.
 *
 * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
 */
public function query()
{
    $proiodas = Proioda::query();

    return $this->applyScopes($proiodas);
}

/**
 * Optional method if you want to use html builder.
 *
 * @return \Yajra\Datatables\Html\Builder
 */
public function html()
{
    return $this->builder()
        ->columns($this->getColumns())
        ->addAction(['width' => '10%'])
        ->ajax('')
        ->parameters([
            'dom' => 'Bfrtip',
            'scrollX' => false,
            'buttons' => [
                'print',
                'reset',
                'reload',
                [
                     'extend'  => 'collection',
                     'text'    => '<i class="fa fa-download"></i> Export',
                     'buttons' => [
                         'csv',
                         'excel',
                         'pdf',
                     ],
                ],
                'colvis'
            ]
        ]);
}

/**
 * Get columns.
 *
 * @return array
 */
private function getColumns()
{
    return [
        'onoma' => ['name' => 'onoma', 'data' => 'onoma'],
        'perigrafi' => ['name' => 'perigrafi', 'data' => 'perigrafi'],
        'timi' => ['name' => 'timi', 'data' => 'timi']
    ];
}

/**
 * Get filename for export.
 *
 * @return string
 */
protected function filename()
{
    return 'proiodas';
}
}

Can someone help me please!!



via Eth0

Advertisement