lundi 16 août 2021

"Target class [Modules\\Admins\\Controllers\\AdminController] does not exist."

I'm developing an e-commerce website using Laravel 8, And I tried to change on Laravel folders structure I've put views folder inside new path modules/admins which works fine, and I've also created a Models folder in the modules/admins path which works fine, however, I am having trouble with the controllers folder.

I still have the app/http/controllers/Controller.php, but now I've created a folder called Controllers inside the modules folder, and in it I have a controller called AdminController

error message: "Target class [Modules\Admins\Controllers\AdminController] does not exist."

AdminController file


namespace Modules\Admins\Controllers;

use App\Http\Controllers\BaseController;
use App\Http\Traits\ApiDesignTrait;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\{
    Hash, Validator
};
class AdminController extends BaseController
{
    public function test()
    {
        return true;
    }
}

route.php

use Illuminate\Support\Facades\Route;
use Modules\Admins\Controllers\AdminController;

Route::post('/test',  [AdminController::class, 'test']);

BaseController.php


namespace App\Http\Controllers;

use App\Http\Controllers\Controller;


class BaseController extends Controller
{

}

Controller.php


namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
}

Aucun commentaire:

Enregistrer un commentaire