diff --git a/packages/Webkul/Cart/src/Cart.php b/packages/Webkul/Cart/src/Cart.php index d5b2a571a..094ca5330 100644 --- a/packages/Webkul/Cart/src/Cart.php +++ b/packages/Webkul/Cart/src/Cart.php @@ -4,14 +4,11 @@ namespace Webkul\Cart; use Carbon\Carbon; -//Cart repositories use Webkul\Cart\Repositories\CartRepository; use Webkul\Cart\Repositories\CartItemRepository; -//Customer repositories use Webkul\Customer\Repositories\CustomerRepository; -//Product Repository use Webkul\Product\Repositories\ProductRepository; use Cookie; @@ -24,12 +21,11 @@ use Cookie; * @author Prashant Singh * @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ - class Cart { - protected $cart; //item repository instance + protected $cart; //cart repository instance - protected $cartItem; //cart item repository instance + protected $cartItem; //cart_item repository instance protected $customer; //customer repository instance @@ -50,17 +46,20 @@ class Cart { } /** - * Create New Cart - * Cart, Cookie & - * Session. + * Create new cart + * instance with the + * current item added. * - * @return mixed - */ + * @param @id + * @param $data + * + * @return Mixed + */ public function createNewCart($id, $data) { $cartData['channel_id'] = core()->getCurrentChannel()->id; if(auth()->guard('customer')->check()) { - $data['customer_id'] = auth()->guard('customer')->user()->id; + $cartData['customer_id'] = auth()->guard('customer')->user()->id; $cartData['customer_full_name'] = auth()->guard('customer')->user()->first_name .' '. auth()->guard('customer')->user()->last_name; } @@ -82,18 +81,18 @@ class Cart { return redirect()->back(); } - /* - handle the after login event for the customers - when their are pruoducts in the session or cookie - of the logged in user. - */ - + /** + * Add Items in a + * cart with some + * cart and item + * details. + * + * @param @id + * @param $data + * + * @return Mixed + */ public function add($id, $data) { - - // session()->forget('cart'); - - // return redirect()->back(); - if(session()->has('cart')) { $cart = session()->get('cart'); @@ -145,11 +144,13 @@ class Cart { } /** - * Function to handle merge - * and sync the cookies products - * with the existing data of cart - * in the cart tables; - */ + * This function handles + * when guest has some of + * cart products and then + * logs in. + * + * @return Redirect + */ public function mergeCart() { if(session()->has('cart')) { $cart = session()->get('cart'); @@ -200,19 +201,4 @@ class Cart { return redirect()->back(); } } - - /** - * Destroys the session - * maintained for cart - * on customer logout. - * - * @return Mixed - */ - public function destroyCart() { - if(session()->has('cart')) { - session()->forget('cart'); - - return redirect()->back(); - } - } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/Controllers/CartController.php b/packages/Webkul/Cart/src/Http/Controllers/CartController.php index c3ee9ee9f..5b77c35d4 100644 --- a/packages/Webkul/Cart/src/Http/Controllers/CartController.php +++ b/packages/Webkul/Cart/src/Http/Controllers/CartController.php @@ -100,13 +100,14 @@ class CartController extends Controller } /** - * This is a test for - * relationship existence - * from cart item to product + * This method will return + * the quantities from + * inventory sources whose + * status are not false. * * @return Array */ - public function test() { + public function canAddOrUpdate() { $cart = $this->cart->findOneByField('id', 144); $items = $cart->items; @@ -147,6 +148,9 @@ class CartController extends Controller dump($inventory->status); } } + } + + public function test() { } } \ No newline at end of file diff --git a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php index 210e95017..372f40d14 100644 --- a/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php +++ b/packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php @@ -9,8 +9,6 @@ use Webkul\Cart\Repositories\CartRepository; use Webkul\Cart\Repositories\CartItemRepository; - -use Cookie; use Cart; /** * cart List Composer on Navigation Menu @@ -57,11 +55,11 @@ class CartComposer $view->with('cart', $cart_products); } } else { - if(Cookie::has('cart_session_id')) { - $cart = $this->cart->findOneByField('session_id', Cookie::get('cart_session_id')); + if(session()->has('cart')) { + $cart = session()->get('cart'); if(isset($cart)) { - $cart_items = $this->cart->items($cart['id']); + $cartItems = $this->cart->items($cart['id']); $cart_products = array(); diff --git a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php index 67ea8ba65..656bb73fc 100644 --- a/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php +++ b/packages/Webkul/Customer/src/Http/Controllers/RegistrationController.php @@ -31,7 +31,10 @@ class RegistrationController extends Controller } /** - * For showing the registration form + * Opens up the + * user's sign up + * form. + * * @return view */ public function show() @@ -40,9 +43,11 @@ class RegistrationController extends Controller } /** - * For collecting the registration - * data from the registraion form - * @return view + * Method to store + * user's sign up + * form data to DB + * + * @return Mixed */ public function create(Request $request) { @@ -52,13 +57,17 @@ class RegistrationController extends Controller 'first_name' => 'string|required', 'last_name' => 'string|required', 'email' => 'email|required', - 'password' => 'confirmed|min:6|required' - + 'password' => 'confirmed|min:6|required', + 'agreement' => 'confirmed' ]); - $registrationData = $request->except('_token'); + $data = request()->input(); - if ($this->customer->create($registrationData)) { + $data['password'] = bcrypt($data['password']); + + // $registrationData = $request->except('_token'); + + if ($this->customer->create($data)) { session()->flash('success', 'Account created successfully.'); diff --git a/packages/Webkul/Shop/src/Resources/views/customers/signup/index.blade.php b/packages/Webkul/Shop/src/Resources/views/customers/signup/index.blade.php index ecc0e4564..21c916675 100644 --- a/packages/Webkul/Shop/src/Resources/views/customers/signup/index.blade.php +++ b/packages/Webkul/Shop/src/Resources/views/customers/signup/index.blade.php @@ -18,31 +18,31 @@
- + @{{ errors.first('first_name') }}
- + @{{ errors.first('last_name') }}
- + @{{ errors.first('email') }}
- + @{{ errors.first('password') }}
- + @{{ errors.first('confirm_password') }}