diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..37d2d57 --- /dev/null +++ b/app/Http/Controllers/HomeController.php @@ -0,0 +1,33 @@ +middleware('auth'); + } + + /** + * Show the application dashboard. + * + * @return \Illuminate\Contracts\Support\Renderable + */ + public function index() + { + + if(auth()->user()->is_admin==1){ + return redirect()->to('auth/dashboard'); + } + return redirect()->to('/'); + + } +} diff --git a/routes/web.php b/routes/web.php index 2a066be..ec20eec 100644 --- a/routes/web.php +++ b/routes/web.php @@ -4,6 +4,7 @@ use App\Http\Controllers\FrontProductListController; use App\Http\Controllers\CartController; use App\Http\Controllers\ProductController; +use App\Http\Controllers\HomeController; // Route::get('/', 'FrontProductListController@index'); Route::get('/', [FrontProductListController::class, 'index']); @@ -22,11 +23,11 @@ // Auth::routes(); Route::get('all/products', [FrontProductListController::class, 'moreProducts'])->name('more.product'); -// Route::get('/home', 'HomeController@index')->name('home'); +Route::get('/home', [HomeController::class, 'index'])->name('home'); // Route::get('subcatories/{id}', 'ProductController@loadSubCategories'); Route::get('/dashboard', function () { - return view('dashboard'); + return redirect('/'); })->middleware(['auth', 'verified'])->name('dashboard'); // Route::middleware('auth')->group(function () {