/** * Display a listing of the resource. * * @return Response */ public function index($type = null) { $this->layout = 'categories.index'; $this->metas['title'] = trans('project.categories'); $this->view = $this->BuildLayout(); if ($type == null) { $categoryTypes = CategoryType::all(); return $this->view->withCategoryTypes($categoryTypes); } else { $typId = CategoryType::where('slug', $type)->first()->id; $categories = Category::where('type', $typId)->orderBy('position')->get(); return $this->view->withCategories($categories); } }
public function getTypetitleAttribute() { $return = CategoryType::where('id', $this->type)->first(); return $return->title; }