Home > Software engineering >  How to display message after registration Laravel Jetstream
How to display message after registration Laravel Jetstream

Time:09-30

Hi im trying figure out how to display message(toastr) after successful registration, im using laravel 8 with jetstream authetication, so far i couldnt find anything useful on google... by the way im in RegistredUserController.php

 public function store(Request $request,
                      CreatesNewUsers $creator): RegisterResponse
{
    event(new Registered($user = $creator->create($request->all())));

    $this->guard->login($user);

    return app(RegisterResponse::class);
}

i tried modifying this block of code but nothing is working... Im new on laravel Any suggestions will be much appreciated!

CodePudding user response:

So i will add answer to myself using Jetstram is pain in the ass, simply i started new project with breeze and i can easy set up toastr messages after registration .

    public function store(Request $request)
{
    $request->validate([
        'first_name' => ['required', 'string', 'max:255'],
        'last_name' => ['required', 'string', 'max:255'],
        'username' => ['required', 'string', 'max:255', 'unique:users'],
        'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
        'is_vendor' => ['required', 'integer', 'max:255'],
        'password' => ['required', 'confirmed', Rules\Password::defaults()],
    ]);

    $user = User::create([
        'first_name' => $request->first_name,
        'last_name' => $request->last_name,
        'username' => $request->username,
        'email' => $request->email,
        'is_vendor' => $request->is_vendor,
        'password' => Hash::make($request->password),
    ]);

    event(new Registered($user));

    //Auth::login($user);
    $notification = array(
        'message' => 'Registration Completed!',
        'alert-type' => 'success'
    );
    return Redirect()->route('login')->with($notification);
    //return redirect(RouteServiceProvider::HOME)->with($notification);
}
  • Related