Home > database >  Target class [VerificationController] does not exist. using laravel 8
Target class [VerificationController] does not exist. using laravel 8

Time:06-02

I am using laravel package Email verification after registration i am trying to register after that i am directory moving to dashboard instead of email verify page when i open url http://localhost/wfh_cms/public/email/verify but i am getting error Target class [VerificationController] does not exist. please help me how can i resolved that ?

Note :- After registration why am i not redirect to email/verify url currently going to dashboard.

please check error

https://flareapp.io/share/q5YENnx5

routes\web.php

  Route::group(['middleware' => ['auth']], function() {

                /**
                 * Logout Routes
                 */
                Route::get('/logout', [LogoutController::class,'logout'])->name('logout');

                /**
                 * Verification Routes
                 */
                Route::get('/email/verify', 'VerificationController@show')->name('verification.notice');
                Route::get('/email/verify/{id}/{hash}', 'VerificationController@verify')->name('verification.verify')->middleware(['signed']);
                Route::post('/email/resend', 'VerificationController@resend')->name('verification.resend');
     });

    Route::group(['middleware' => ['auth','verified']], function() {

       Route::get('/notification',[NotificationController::class,'index'])- 
      >name('notifications');

     });

app\Http\Controllers\VerificationController.php

class VerificationController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Email Verification Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling email verification for any
    | user that recently registered with the application. Emails may also
    | be re-sent if the user didn't receive the original email message.
    |
    */

    use VerifiesEmails, RedirectsUsers;

    /**
     * Where to redirect users after verification.
     *
     * @var string
     */
    protected $redirectTo = '/dashboard';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
        $this->middleware('signed')->only('verify');
        $this->middleware('throttle:6,1')->only('verify', 'resend');
    }

    /**
     * Show the email verification notice.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
     */
    public function show(Request $request)
    {
        return $request->user()->hasVerifiedEmail()
                        ? redirect($this->redirectPath())
                        : view('web.verification.verify-email', [
                            'pageTitle' => __('Account Verification')
                        ]);
    }
}

CodePudding user response:

dont forget to import controller like :

use App\Http\Controllers\HomeController;

CodePudding user response:

Make sure you have defined namespace at top of controller file.

namespace App\Http\Controllers;

CodePudding user response:

I think you forget to use VerificationController in the top of your web.php file. Add this in the top of your web.php

use App\Http\Controllers\VerificationController;

Reference: Routing in Laravel

  • Related