After successfully login, redirect with define user role it is return an error that route not defined.
InvalidArgumentException Route [list-activity] not defined.
file path : vendor\laravel\framework\src\Illuminate\Foundation\Auth\AuthenticatesUser.php
Function:
protected function authenticated(Request $request, $user)
{
if($user->user_role=='Admin'){
return redirect()->route('list-activity') ; // return error
}elseif($user->role=='User'){
return redirect()->route('front.welcome') ;
}
}
My web.php file code
Route::get('/', function () { return view('front.welcome'); });
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::middleware(['web', 'navigation'])->group(function () {
require_once("admin/web.php"); });
Note: Added web.php file on admin folder
My routes admin\web.php file code
Route::middleware(['auth'])->prefix('admin')->namespace('Admin')->group(function() {
Route::get('lists-activity','ActivityController@listactivity')->name('lists-activity'); });
And here is my controller code
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller as BaseController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
class ActivityController extends BaseController
{
public function listactivity() {
dd("hello");
} }
return redirect('admin/lists-activity');
– Sohel0415Class navigation does not exist
– Javednavigation
inApp\Http\Kernel
? You set itRoute::middleware(['web', 'navigation'])
here – Ohgodwhy