/** * Finds a product type by id. * * @param int $id * @param bool $with_attributes * @return ProductType * @throws ModelNotFoundException */ public function findById($id, $with_attributes = false) { return $with_attributes ? ProductType::with('attributes')->findOrFail($id) : ProductType::findOrFail($id); }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { $types = ProductType::with('Products')->get(); return view('home', array('types' => $types)); }
/** * Show the products of a selected type. * * @return \Illuminate\Http\Response */ public function showProductsByType($id) { $type = ProductType::with('Products')->find($id); return view('showProductsByType', array('type' => $type)); }