diff --git a/app/Http/Controllers/AdminController.php b/app/Http/Controllers/AdminController.php index 51530ec..95c8966 100644 --- a/app/Http/Controllers/AdminController.php +++ b/app/Http/Controllers/AdminController.php @@ -2,6 +2,8 @@ namespace App\Http\Controllers; +use App\Models\User; + use Illuminate\Http\Request; use App\Models\Product; @@ -15,6 +17,7 @@ class AdminController extends Controller } return redirect()->back(); } + public function products() { if (session()->get('type') == 'Admin') { @@ -69,7 +72,7 @@ class AdminController extends Controller 'name' => 'required', 'price' => 'required|numeric', 'description' => 'required', - 'file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:10240', 'quantity' => 'required|numeric', 'category' => 'required', 'type' => 'required', @@ -157,4 +160,13 @@ class AdminController extends Controller } return redirect()->back(); } + + public function profile() + { + if (session()->get('type') == 'Admin') { + $user = User::find(session()->get('id')); + return view('Dashboard.profile', compact('user')); + } + return redirect()->back(); + } } diff --git a/app/Http/Controllers/MainController.php b/app/Http/Controllers/MainController.php index ad6d63c..40a78ad 100644 --- a/app/Http/Controllers/MainController.php +++ b/app/Http/Controllers/MainController.php @@ -158,16 +158,19 @@ class MainController extends Controller public function cart() { - $cartItems = DB::table('products') - // ->join('carts', 'carts.productId', '=', 'products.id') - ->join('carts', 'carts.productId', 'products.id') - ->select('products.name', 'products.price', 'products.picture', 'products.quantity as pQuantity', 'carts.*') - ->where('carts.customerId', session()->get('id')) - ->get(); + if (session()->get('type') == 'Customer') { + $cartItems = DB::table('products') + // ->join('carts', 'carts.productId', '=', 'products.id') + ->join('carts', 'carts.productId', 'products.id') + ->select('products.name', 'products.price', 'products.picture', 'products.quantity as pQuantity', 'carts.*') + ->where('carts.customerId', session()->get('id')) + ->get(); - //dd($cartItems); + //dd($cartItems); - return view('cart', compact('cartItems')); + return view('cart', compact('cartItems')); + } + return redirect()->back(); } public function addToCart(Request $data) @@ -231,11 +234,14 @@ class MainController extends Controller public function profile() { - if (session()->has('id')) { - $user = User::find(session()->get('id')); - return view('profile', compact('user')); + if (session()->get('type') == 'Customer') { + if (session()->has('id')) { + $user = User::find(session()->get('id')); + return view('profile', compact('user')); + } + return redirect('login'); } - return redirect('login'); + return redirect()->back(); } public function updateUser(Request $data) @@ -290,22 +296,23 @@ class MainController extends Controller public function testMail() { - $details = [ - 'title' => 'Mail from Uron Shrestha', - 'message' => 'This is for testing mail using smtp in Laravel!' - ]; - Mail::to("yuron.stha57@gmail.com")->send(new Testing($details)); - return redirect('/'); + if (session()->get('type') == 'Customer') { + $details = [ + 'title' => 'Mail from Uron Shrestha', + 'message' => 'This is for testing mail using smtp in Laravel!' + ]; + Mail::to("yuron.stha57@gmail.com")->send(new Testing($details)); + return redirect('/'); + } + return redirect()->back(); } public function shop() { - return view('shop'); - } - - public function shopDetails() - { - return view('shopDetails'); + if (session()->get('type') == 'Customer') { + return view('shop'); + } + return redirect()->back(); } } diff --git a/public/uploads/products/1720951132_team-3.jpg b/public/uploads/products/1720951132_team-3.jpg new file mode 100644 index 0000000..b204dc8 Binary files /dev/null and b/public/uploads/products/1720951132_team-3.jpg differ diff --git a/public/uploads/profiles/team-1.jpg b/public/uploads/profiles/team-1.jpg new file mode 100644 index 0000000..fc83041 Binary files /dev/null and b/public/uploads/profiles/team-1.jpg differ diff --git a/resources/views/Dashboard/profile.blade.php b/resources/views/Dashboard/profile.blade.php new file mode 100644 index 0000000..09637a7 --- /dev/null +++ b/resources/views/Dashboard/profile.blade.php @@ -0,0 +1,71 @@ + + + +
+
+
+
+
+
+

My Profile

+ + @if (session('success')) +
+ {{ session('success') }} +
+ @endif + + @if (session('error')) +
+ {{ session('error') }} +
+ @endif + + @if ($errors->any()) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + profile picture + +
+ @csrf +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + +
+
+
+ +
+
+
+ +
+ +
+ + + diff --git a/resources/views/components/adminheader.blade.php b/resources/views/components/adminheader.blade.php index 74269ad..883a769 100644 --- a/resources/views/components/adminheader.blade.php +++ b/resources/views/components/adminheader.blade.php @@ -406,7 +406,7 @@
diff --git a/routes/web.php b/routes/web.php index 7c52fb8..4d6b29c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,6 +15,7 @@ Route::get('/adminProducts', [AdminController::class, 'products'])->name('produc Route::post('/addNewProduct', [AdminController::class, 'addNewProduct'])->name('addNewProduct'); Route::post('/updateProduct', [AdminController::class, 'updateProduct'])->name('updateProduct'); Route::get('/deleteProduct/{id}', [AdminController::class, 'deleteProduct'])->name('deleteProduct'); +Route::get('/adminProfile', [AdminController::class, 'profile'])->name('adminProfile');