Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
T
test-webshop
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Artem
test-webshop
Commits
02165d9e
Commit
02165d9e
authored
May 08, 2020
by
Artem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add route prefix for /cart, fix bug with update product
parent
44fe43c4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
CartController.php
app/Http/Controllers/CartController.php
+4
-0
web.php
routes/web.php
+7
-5
No files found.
app/Http/Controllers/CartController.php
View file @
02165d9e
...
@@ -34,6 +34,10 @@ class CartController extends Controller
...
@@ -34,6 +34,10 @@ class CartController extends Controller
$products_qty
=
json_decode
(
$request
->
productsQty
,
true
);
$products_qty
=
json_decode
(
$request
->
productsQty
,
true
);
$cart
=
Session
::
get
(
'cart'
);
$cart
=
Session
::
get
(
'cart'
);
$cart
->
updateQty
(
$products_qty
);
$cart
->
updateQty
(
$products_qty
);
if
(
!
$cart
->
total_qty
)
{
Session
::
forget
(
'cart'
);
}
}
}
public
function
removeFromCart
(
Product
$product
)
public
function
removeFromCart
(
Product
$product
)
...
...
routes/web.php
View file @
02165d9e
...
@@ -29,9 +29,11 @@ Auth::routes();
...
@@ -29,9 +29,11 @@ Auth::routes();
Route
::
get
(
'/home'
,
'HomeController@index'
)
->
name
(
'home'
);
Route
::
get
(
'/home'
,
'HomeController@index'
)
->
name
(
'home'
);
Route
::
prefix
(
'cart'
)
->
group
(
function
()
{
Route
::
get
(
'/'
,
'CartController@index'
)
->
name
(
'cart.index'
);
Route
::
post
(
'/add/{product}'
,
'CartController@addToCart'
)
->
name
(
'cart.addToCart'
);
Route
::
post
(
'/update'
,
'CartController@updateQtyInCart'
)
->
name
(
'cart.updateQtyInCart'
);
Route
::
post
(
'/remove/{product}'
,
'CartController@removeFromCart'
)
->
name
(
'cart.removeFromCart'
);
Route
::
post
(
'/clear'
,
'CartController@clearCart'
)
->
name
(
'cart.clearCart'
);
});
Route
::
get
(
'/cart'
,
'CartController@index'
)
->
name
(
'cart.index'
);
Route
::
post
(
'/cart/add/{product}'
,
'CartController@addToCart'
)
->
name
(
'cart.addToCart'
);
Route
::
post
(
'/cart/update'
,
'CartController@updateQtyInCart'
)
->
name
(
'cart.updateQtyInCart'
);
Route
::
post
(
'/cart/remove/{product}'
,
'CartController@removeFromCart'
)
->
name
(
'cart.removeFromCart'
);
Route
::
post
(
'/cart/clear'
,
'CartController@clearCart'
)
->
name
(
'cart.clearCart'
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment