-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a122a8e
commit a24c789
Showing
21 changed files
with
691 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
@section('page_title') | ||
|
||
@endsection | ||
@stop | ||
|
||
@section('content') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/Webkul/Cart/src/Http/ViewComposers/CartComposer.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace Webkul\Cart\Http\ViewComposers; | ||
|
||
use Illuminate\View\View; | ||
use Illuminate\Support\Collection; | ||
|
||
use Webkul\Cart\Repositories\CartRepository; | ||
|
||
use Cookie; | ||
use Cart; | ||
/** | ||
* cart List Composer on Navigation Menu | ||
* | ||
* @author Prashant Singh <prashant.singh852@webkul.com> | ||
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) | ||
*/ | ||
|
||
class CartComposer | ||
{ | ||
|
||
/** | ||
* The cart implementation | ||
* for shop bundle's navigation | ||
* menu | ||
*/ | ||
protected $cart; | ||
|
||
/** | ||
* Bind data to the view. | ||
* | ||
* @param View $view | ||
* @return void | ||
*/ | ||
public function __construct(CartRepository $cart) { | ||
$this->cart = $cart; | ||
} | ||
|
||
public function compose(View $view) { | ||
if(auth()->guard('customer')->check()) { | ||
$cart = $this->cart->findOneByField('customer_id', auth()->guard('customer')->user()->id); | ||
|
||
$cart_products = $this->cart->getProducts($cart['id']); | ||
|
||
// dd($cart_products); | ||
|
||
$view->with('cart', $cart_products); | ||
|
||
} else { | ||
if(Cookie::has('cart_session_id')) { | ||
$cart = $this->cart->findOneByField('session_id', Cookie::get('cart_session_id')); | ||
|
||
$cart_products = $this->cart->getProducts($cart['id']); | ||
|
||
$view->with('cart', $cart_products); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.