嗨我在使用laravel 5.4时出错了我正在使用infyom / laravel-generator软件包当我使用php artisan infyom:scaffold ModelName --datatables = true当我去视图时我得到了错误。
ProiodaController.php第32行中的FatalThrowableError:调用未定义的方法App \ DataTables \ ProiodaDataTable :: render()
这是我的控制器 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'));
}
}
这是 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';
}
}
有人可以帮帮我!!