
PK 
<?php
namespace App\Http\ViewComposers;
use Illuminate\View\View;
use App\Category;
class CategoryComposer
{
protected $categoryList = [];
protected $categoryParentList = [];
/**
* Create a movie composer.
*
* @return void
*/
public function __construct()
{ try{
$this->categoryList = Category::all()->sortByDesc('sortby');
$this->categoryParentList = Category::all()->where('parent_id',0);
//$this->categoryList = Category::all()->sortByDesc('sortby')->toArray();
//$this->categoryParentList = Category::select('id','name','image','isactive','created_at')->get();
}catch(\Exception $e){
return view('errors.500');
//p($e->getMessage()); exit;
}
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
{ $categoryList = $this->categoryList;
$categoryParentList = $this->categoryParentList;
$view->with(compact('categoryList','categoryParentList'));
}
}


PK 99