F
F
fegedij3922020-10-03 21:36:08
Laravel
fegedij392, 2020-10-03 21:36:08

How to prescribe Route in a new way in laravel?

installed according to standard laravel
composer create-project --prefer-dist laravel/laravel blog
latest version installed.
went to routes\web.php and saw this

Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');

and now normal
Route::get('/home', '[email protected]'])->name('home');
work out.

sort of figured out with the usual, it turned out like this
Route::get('/', [App\Http\Controllers\Admin\DashboardController::class, 'dashboard'])->name('admin.index');


but Route::resource does not work,
it looked like this in the old way
Route::resource('/category', 'CategoryController');

if you just write
Route::resource('/category', [App\Http\Controllers\Admin\CategoryController::class,])

it throws an error ErrorException Array to string conversion.

help someone who has already encountered correctly register Route:: resource

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
fegedij392, 2020-10-03
@fegedij392

found a solution

Route::resource('/category', '\App\Http\Controllers\Admin\CategoryController');

V
Vladimir Kokhan, 2020-10-04
@SkazochNick

Read here - https://laravel.demiart.ru/target-class-does-not-e...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question