1

I know this question may sound stupid, but I'm working with Laravel, and I want to return an alert message for one of my route which is placed inside of a group route:

Route::middleware('auth')->group(function(){
    Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
        alert()->success('welcome','message')->persistent('Ok');
    }
    Route::get('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'manageTwoFactor'])->name('profile.2fa.manage');
    Route::post('profile/twofactor', [App\Http\Controllers\ProfileController::class, 'postManageTwoFactor']);
});

As you can see for the route profile I have set this message but I get ParseError syntax error, unexpected ';'.

Unfortunately I don't know how to do this in a proper way.

So if you know, please help me out.

Thanks!

4
  • as error says you forgot to put ; after your Route alerts end Commented Dec 1, 2020 at 6:17
  • @NurbekBoymurodov If you mean this line: alert()->success('welcome','message')->persistent('Ok');, then it is ended with ; Commented Dec 1, 2020 at 6:19
  • not there check thisRoute::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){ alert()->success('welcome','message')->persistent('Ok'); }; here Commented Dec 1, 2020 at 6:21
  • @NurbekBoymurodov No man! I have tried that one, but didn't solve the problem. Commented Dec 1, 2020 at 6:22

1 Answer 1

2

Check that line:

Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile'){
    alert()->success('welcome','message')->persistent('Ok');
}

You have curly braces around alert()..., that is mistake.

You should change it to:

Route::get('profile', [App\Http\Controllers\ProfileController::class, 'index'])->name('profile');

And move alert()->success('welcome','message')->persistent('Ok'); to the index method of the ProfileController class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.