Skip to content

Commit

Permalink
add home controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mranidev committed Aug 23, 2024
1 parent 512ae24 commit 113ccac
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
33 changes: 33 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->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('/');

}
}
5 changes: 3 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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 () {
Expand Down

0 comments on commit 113ccac

Please sign in to comment.