Skip to content

Commit 113ccac

Browse files
committed
add home controller
1 parent 512ae24 commit 113ccac

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace App\Http\Controllers;
4+
5+
use Illuminate\Http\Request;
6+
7+
class HomeController extends Controller
8+
{
9+
/**
10+
* Create a new controller instance.
11+
*
12+
* @return void
13+
*/
14+
public function __construct()
15+
{
16+
$this->middleware('auth');
17+
}
18+
19+
/**
20+
* Show the application dashboard.
21+
*
22+
* @return \Illuminate\Contracts\Support\Renderable
23+
*/
24+
public function index()
25+
{
26+
27+
if(auth()->user()->is_admin==1){
28+
return redirect()->to('auth/dashboard');
29+
}
30+
return redirect()->to('/');
31+
32+
}
33+
}

routes/web.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use App\Http\Controllers\FrontProductListController;
55
use App\Http\Controllers\CartController;
66
use App\Http\Controllers\ProductController;
7+
use App\Http\Controllers\HomeController;
78

89
// Route::get('/', 'FrontProductListController@index');
910
Route::get('/', [FrontProductListController::class, 'index']);
@@ -22,11 +23,11 @@
2223
// Auth::routes();
2324

2425
Route::get('all/products', [FrontProductListController::class, 'moreProducts'])->name('more.product');
25-
// Route::get('/home', 'HomeController@index')->name('home');
26+
Route::get('/home', [HomeController::class, 'index'])->name('home');
2627
// Route::get('subcatories/{id}', 'ProductController@loadSubCategories');
2728

2829
Route::get('/dashboard', function () {
29-
return view('dashboard');
30+
return redirect('/');
3031
})->middleware(['auth', 'verified'])->name('dashboard');
3132

3233
// Route::middleware('auth')->group(function () {

0 commit comments

Comments
 (0)