laravel-8

Array to string conversion error in resource controller in laravel8


I am using laravel8. I created resource controller. when I am using get method for that then it is giving error.

My route is:

Route::resource('/details', [App\Http\Controllers\detailController::class]);

In resource controller, I have index method:

 public function index()
{
   echo 'dd';
}

when I run http://127.0.0.1:8000/details I am getting error.

ErrorException
 Array to string conversion
 http://127.0.0.1:8000/details

Solution

  • You just have to remove array syntax form the controller name

    Route::resource('/details', App\Http\Controllers\detailController::class);