0

I created a Model, Controller, Factory and dataTable files, but laravel keeps showing me the error $dataTable is undefined

How come? Is it a routing issue or I'm not linking the controller to the blade correctly?

My controller:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\DataTables\DataEntry\ReportsDataTable;

class ReportsController extends Controller
{
    public function index(ReportsDataTable $dataTable)
    {
        return $dataTable->render("pages.dataEntry.reports.index");
    }
}

The Route:

// Data Entry pages
    Route::prefix('dataEntry')->name('dataEntry.')->group(function () {
        Route::resource('reports', ReportsController::class)->only(['index']);
    });

index.blade:

<x-base-layout>

    <!--begin::Card-->
    <div class="card">
        <!--begin::Card body-->
        <div class="card-body pt-6">
            <!--begin::Table-->
             {{ $dataTable->table() }}
            <!--end::Table-->

            {{-- Inject Scripts --}}
             {{ $dataTable->scripts() }}
        </div>
        <!--end::Card body-->
    </div>
    <!--end::Card-->

</x-base-layout>
Abdulrahman Mushref
  • 1,012
  • 2
  • 18
  • 40

1 Answers1

0
public function index()
{
    return ReportsDataTable::all()->render("pages.dataEntry.reports.index");
}