Created
April 26, 2016 23:27
-
-
Save ChadTaljaardt/bf77bd438ba58d836253668592d26836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
namespace App\Http\ViewComposers; | |
use Illuminate\View\View; | |
use App\Models\Store\Cart as Cart; | |
use Auth; | |
use App\Categories as Categories; | |
class HeaderComposer | |
{ | |
protected $cartCount; | |
public function __construct() | |
{ | |
if(Auth::user()) | |
{ | |
$cart = Cart::current(); | |
$this->cartCount = $cart->items()->count(); | |
} else { | |
$this->cartCount = 0; | |
} | |
} | |
public function compose(View $view) | |
{ | |
$categories = Categories::where('enabled', '1')->get(); | |
$view->with(['count' => $this->cartCount, 'categories' => $categories]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment