lundi 25 mai 2020

Change location Controllers\Auth

I make project in Laravel 7. I change location Http\Controllers\Auth to Http\Controllers**Admin**\Auth

In all files in Auth directory I change namespaces:

from:

namespace App\Http\Controllers\Auth;

to

namespace App\Http\Controllers\Admin\Auth;

Them I make composer dump-autoload.

Login work fine.

Now when I try logout with my code:

<a href=""
                       onclick="event.preventDefault(); document.getElementById('logout-form').submit();" class="btn btn-sm btn-light-primary font-weight-bolder py-2 px-5">Wyloguj</a>
                    <form id="logout-form" action="" method="POST" style="display: none;">
                        @csrf
                    </form>

I have error:

Illuminate\Contracts\Container\BindingResolutionException Target class [App\Http\Controllers\Front\Auth\LoginController] does not exist.

My RouteServiceProvider:

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * The path to the "home" route for your application.
     *
     * @var string
     */
    public const HOME = '/';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        //

        parent::boot();
    }

    /**
     * Define the routes for the application.
     *
     * @return void
     */
    public function map()
    {
        $this->mapApiRoutes();

        if(config('app.admin_only'))
        {
            $this->mapAdminOnlyRoutes();
        }
        else
        {
            $this->mapWebRoutes();
            $this->mapAdminRoutes();
        }
    }

    /**
     * Define the "web" routes for the application.
     *
     * These routes all receive session state, CSRF protection, etc.
     *
     * @return void
     */
    protected function mapWebRoutes()
    {
        Route::middleware('web')
            ->namespace($this->namespace. '\Front')
            ->group(base_path('routes/web.php'));
    }

    /**
     * Define the "api" routes for the application.
     *
     * These routes are typically stateless.
     *
     * @return void
     */
    protected function mapApiRoutes()
    {
        Route::prefix('api')
            ->middleware('api')
            ->namespace($this->namespace)
            ->group(base_path('routes/api.php'));
    }

    protected function mapAdminRoutes()
    {
        Route::prefix(config('app.admin_prefix'))
            ->middleware('web')
            ->namespace($this->namespace.'\Admin')
            ->group(base_path('routes/admin.php'));
    }

    protected function mapAdminOnlyRoutes()
    {
        Route::middleware('web')
            ->namespace($this->namespace. '\Admin')
            ->group(base_path('routes/admin.php'));
    }
}

What is wrong? How can I repair it?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LWOFiB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire