diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 009a50b..cadc1a0 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -1,6 +1,7 @@ role) { case 'admin': - return redirect('/admin')->with('alert', [ - 'code' => 'success', - 'title' => 'Success!', - 'subtitle' => 'You have been logged in as an admin!', - ]); + return redirect('/admin')->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Bonjour!', + 'subtitle' => 'You have been logged in as an admin!', + ]) + ); break; case 'sysadmin': - return redirect('/admin')->with('alert', [ - 'code' => 'success', - 'title' => 'Success!', - 'subtitle' => 'You have been logged in as an system admin!', - ]); + return redirect('/admin')->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Bonjour!', + 'subtitle' => + 'You have been logged in as an system admin!', + ]) + ); break; case 'seller': - return redirect('/seller')->with('alert', [ - 'code' => 'success', - 'title' => 'Success!', - 'subtitle' => 'You have been logged in as an seller!', - ]); + return redirect('/seller')->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Bonjour!', + 'subtitle' => 'You have been logged in as an seller!', + ]) + ); break; default: - return redirect('home')->with('alert', [ - 'code' => 'success', - 'title' => 'Success!', - 'subtitle' => 'You have been logged in as an customer!', - ]); + return redirect('home')->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Bonjour!', + 'subtitle' => 'You have been logged in as an customer!', + ]) + ); break; } } @@ -92,9 +106,21 @@ public function login(Request $request) } if (Auth::attempt($credentials)) { - return redirect()->intended($this->redirectPath()); + return redirect() + ->intended($this->redirectPath()) + ->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Bonjour!', + 'subtitle' => + 'You have been logged in as an ' . + Auth::user()->role . + '!', + ]) + ); } - + return redirect() ->back() ->withInput() @@ -147,4 +173,19 @@ public function validateLogin(Request $request) 'errors' => ['email' => 'Invalid credentials.'], ]); } + + public function logout(Request $request) + { + Auth::logout(); + return redirect() + ->route('welcome') + ->with( + 'alert', + Notiflix::make([ + 'code' => 'success', + 'title' => 'Adieu!', + 'subtitle' => 'You have been logged out!', + ]) + ); + } } diff --git a/app/Http/Controllers/OrderController.php b/app/Http/Controllers/OrderController.php index cd80145..ac377c1 100644 --- a/app/Http/Controllers/OrderController.php +++ b/app/Http/Controllers/OrderController.php @@ -225,7 +225,7 @@ public function showall() ->orderBy('order_id', 'desc') ->orderBy('created_at', 'desc') ->paginate(8); - return view('profile.orders', compact('orders')); + return view('profile.order.list', compact('orders')); } /** @@ -241,7 +241,7 @@ public function showone($id) 'order_id' => $id, ])->get(); if (count($orders) > 0) { - return view('profile.order', compact('orders')); + return view('profile.order.show', compact('orders')); } abort(404); } @@ -249,13 +249,14 @@ public function cancel_delete(Request $req) { $ostatus = $req->input('input'); $oid = $req->input('id'); - $order = Order::all()->where('id',"=",$oid)->first(); - if($ostatus=="Cancel") - { + $order = Order::all() + ->where('id', '=', $oid) + ->first(); + if ($ostatus == 'Cancel') { $order->status = 'Cancelled'; $order->save(); return redirect() - ->route('orders.show',$order->order_id) + ->route('orders.show', $order->order_id) ->with( 'alert', Notiflix::make([ @@ -265,9 +266,7 @@ public function cancel_delete(Request $req) 'subtitle' => 'Order is successfully Cancellerd!', ]) ); - } - elseif($ostatus=="Delete") - { + } elseif ($ostatus == 'Delete') { Order::find($oid)->delete(); return redirect() ->route('orders') @@ -280,7 +279,7 @@ public function cancel_delete(Request $req) 'subtitle' => 'Order is successfully Deleted!', ]) ); - } + } } /** * Update the specified resource in storage. diff --git a/app/Http/Controllers/SellerController.php b/app/Http/Controllers/SellerController.php index 7b513c0..ac7ea65 100644 --- a/app/Http/Controllers/SellerController.php +++ b/app/Http/Controllers/SellerController.php @@ -23,13 +23,14 @@ public function __construct() public function seller_form() { if (Auth::user()->is_seller || Auth::user()->is_admin) { - return redirect()->back() + return redirect() + ->back() ->with( 'alert', Notiflix::make([ 'code' => 'info', 'subtitle' => - 'You are already registered as ' . + 'You are already registered as ' . Auth::user()->role . '!', ]) @@ -48,7 +49,7 @@ public function seller_form() 'type' => 'Report', 'title' => 'Waiting!', 'subtitle' => - 'Already signed for ' . + 'Already signed for ' . str_replace('_', ' ', $approval->type) . '!', ]) @@ -131,7 +132,7 @@ protected function create_seller(Request $req) 'title' => 'Yippee!', 'type' => 'Report', 'subtitle' => - 'Your registration as a seller is in progress!', + 'Your registration as a seller is in progress!', ]) ); } @@ -162,7 +163,7 @@ public function product_orders() ->orderBy('created_at', 'desc') ->paginate(8); - return view('seller.orders')->with('orders', $orders); + return view('seller.order.list')->with('orders', $orders); } public function show_one_order($id) @@ -175,7 +176,7 @@ public function show_one_order($id) ->where('order_id', $id) ->get(); if (count($orders) > 0) { - return view('profile.order', compact('orders')); + return view('seller.order.show', compact('orders')); } abort(404); } diff --git a/database/seeds/ProductSeeder.php b/database/seeds/ProductSeeder.php index 3ac991c..df51f8a 100644 --- a/database/seeds/ProductSeeder.php +++ b/database/seeds/ProductSeeder.php @@ -327,7 +327,7 @@ public function run() 'ref_id' => $product12->id, ]); - for ($i = 0; $i < 0; $i++) { + for ($i = 0; $i < 50; $i++) { $product_name = $this->faker->bothify('Product**##'); $product = Product::create([ 'type' => array_rand(Product::$categories), diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php index a78d7ec..a46cd4b 100644 --- a/database/seeds/UserSeeder.php +++ b/database/seeds/UserSeeder.php @@ -95,5 +95,17 @@ public function run() 'landmark' => $this->faker->secondaryAddress(), 'type' => $this->faker->randomElement(['Home', 'Work']), ]); + $address2 = Address::create([ + 'user_id' => $user3->id, + 'name' => $this->faker->name(), + 'mobile' => (int) $this->faker->regexify('[1-9]{1}[0-9]{9}'), + 'address1' => $this->faker->buildingNumber(), + 'address2' => $this->faker->streetName(), + 'city' => $this->faker->city(), + 'state' => $this->faker->state(), + 'pincode' => (int) $this->faker->postcode(), + 'landmark' => $this->faker->secondaryAddress(), + 'type' => $this->faker->randomElement(['Home', 'Work']), + ]); } } diff --git a/resources/views/profile/orders.blade.php b/resources/views/profile/order/list.blade.php similarity index 100% rename from resources/views/profile/orders.blade.php rename to resources/views/profile/order/list.blade.php diff --git a/resources/views/profile/order.blade.php b/resources/views/profile/order/show.blade.php similarity index 100% rename from resources/views/profile/order.blade.php rename to resources/views/profile/order/show.blade.php diff --git a/resources/views/seller/orders.blade.php b/resources/views/seller/order/list.blade.php similarity index 60% rename from resources/views/seller/orders.blade.php rename to resources/views/seller/order/list.blade.php index 228a76e..7a5f91a 100644 --- a/resources/views/seller/orders.blade.php +++ b/resources/views/seller/order/list.blade.php @@ -4,40 +4,25 @@
-

My Received Orders -

+

My Orders


@if (count($orders) > 0) @foreach ($orders as $o)
-
- - - +
-
- - - {{ $o->product->name }} - - +
+ {{ $o->product->name }} , - - {{ $o->product->category }} - - {{ $o->qty . ' ' . $o->product->unit }} + {{ $o->product->category }} - 1 {{ $o->product->unit }}
- - {{ $o->product->seller->trade_name }} - + {{ $o->product->seller->trade_name }}
₹ {{ sprintf('%.2f', $o->total_discounted_price) }} @@ -56,19 +41,21 @@ class="uk-text-muted uk-text-strikethrough uk-text-small uk-margin-small-left">
Ordered On: {{ $o->created_at }} +
+ Order Status : + {{ $o->status }}
- @endforeach {{ $orders->links() }} @else
-

You have not orders yet

+

No Order History

@endif - - Back To Dashboard + + Back To Home
diff --git a/resources/views/seller/order/show.blade.php b/resources/views/seller/order/show.blade.php new file mode 100644 index 0000000..3bbe758 --- /dev/null +++ b/resources/views/seller/order/show.blade.php @@ -0,0 +1,72 @@ +@extends('layouts.app') + +@section('content') +
+
+
+

Order Details

+
+ + @if (count($orders) > 0) + @foreach ($orders as $o) +
+
+ {{--
ORDER DETAILS
--}} +
+ +
+
+ {{ $o->product->name }} + , + {{ $o->product->category }} - 1 {{ $o->product->unit }} +
+
+ {{ $o->product->seller->trade_name }} +
+
+ ₹{{ sprintf('%.2f', $o->total_discounted_price) }} + + ₹ {{ sprintf('%.2f', $o->total_price) }} + +
+
+ Quantity : {{ $o->qty }} +
+
+
+
+ +
+ {{--
ADDRESS DETAILS +
--}} +
+ {{ $o->address->name }} +
+ Phone : {{ $o->address->mobile }} +
+ {{ $o->address->full_address }} +
+ Ordered on : + {{ $o->created_at }} +
+ Order Status : {{ $o->status }} +
+ +
+
+ @endforeach + @else +
+

No Order History

+
+ @endif +
+ + Back To Orders + +
+
+
+@endsection diff --git a/routes/web.php b/routes/web.php index 6d48114..7630fb8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -25,13 +25,6 @@ // Profile routes Route::get('/profile/account', 'CustomerController@profile')->name('profile'); -Route::get('/seller/register', 'SellerController@seller_form')->name( - 'seller.register' -); -Route::post('/seller/create', 'SellerController@create_seller')->name( - 'seller.create' -); - Route::get('/explore', 'AppController@explore')->name('explore'); Route::get('/profile', 'CustomerController@index')->name('customer.index'); @@ -60,6 +53,12 @@ ); // Seller Routes +Route::get('/seller/register', 'SellerController@seller_form')->name( + 'seller.register' +); +Route::post('/seller/create', 'SellerController@create_seller')->name( + 'seller.create' +); Route::get('/seller', 'SellerController@index')->name('seller.index'); Route::get('/seller/products', 'SellerController@product_display')->name( 'seller.product.browse' @@ -126,7 +125,9 @@ Route::get('/orders', 'OrderController@showall')->name('orders'); Route::get('/orders/{id}', 'OrderController@showone')->name('orders.show'); -Route::post('/orders/{id}', 'OrderController@cancel_delete')->name('orders.show.cancel.delete'); +Route::post('/orders/{id}', 'OrderController@cancel_delete')->name( + 'orders.show.cancel.delete' +); // Address Routes Route::get('/address', 'AddressController@address_view')->name('address');