Norgul
Norgul

Reputation: 4783

Laravel route:list error returned

When I try to run route:list I get this error:

PHP Fatal error:  Cannot declare class App\Http\Controllers\UserController, 
because the name is already in use in 
/home/vagrant/Code/nomads/app/Http/Controllers/Admin/UserController.php on line 0

[Symfony\Component\Debug\Exception\FatalErrorException]
Cannot declare class App\Http\Controllers\UserController, because the name is already in use

I have UserController under controllers and also Admin folder under which is another UserController.

I am also using AdminLTE package but I have overriden package routes and am using Laravels native routes.

Upvotes: 0

Views: 214

Answers (2)

Tanvir Anowar
Tanvir Anowar

Reputation: 75

You can use Namespace alias ("as") during using it like bellow.

use App\Http\Controllers\Admin\UserController as AdminUserController;

Upvotes: 1

Edvard Åkerberg
Edvard Åkerberg

Reputation: 2191

Change admin/UserController to AdminController and extend the class UserController if you really wanna do this.

use App\Http\Controllers\UserController;

class AdminController extends UserController 
{

Upvotes: 0

Related Questions