0

I founnd this topic: Target class controller does not exist - Laravel 8, so in web.php I wrote:

use App\Http\Controllers\UserController;
//...
Route::get('/units', [UnitsController::class, 'getAllUnits']);
Route::get('/units2', 'App\Http\Controllers\UnitsController@getAllUnits');

But any time I have this same error:

Target class [UnitsController] does not exist.

second address works but it's so long and ugly. Why first address doesn;t work?

Kloc2243
  • 69
  • 6

1 Answers1

0

change namespace from

use App\Http\Controllers\UserController;

to

 use App\Http\Controllers\UnitsController;
Palak Jadav
  • 1,202
  • 1
  • 11
  • 23