/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $category = Category::find($id); if (!$category) { return response()->json(['message' => 'This category does not exist', 'success' => 0, 'code' => 404], 404); } return $category; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function details($id) { $category = Category::find($id); if ($category) { $category_company = $category->companies; return view('categories.details')->with(['category' => $category, 'category_company' => $category_company]); } return view('categories.index'); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(CreateCompanyRequest $request) { $name = $request->get('name'); $information = $request->get('information'); $email = $request->get('email'); $year_estab = $request->get('year_estab'); $address = $request->get('address'); $cat_id = $request->get('category_id'); $user_id = $request->get('user_id'); $category = Category::find($cat_id); $category->companies()->create(['name' => $name, 'information' => $information, 'email' => $email, 'year_estab' => $year_estab, 'address' => $address, 'category_id' => $cat_id, 'user_id' => $user_id]); return redirect('categories_web')->with(['company_created' => 'The Company has been created.']); }