public function pullCategories() { $uri = 'https://tartan.plaid.com/categories'; $client = new Client(); $response = $client->get($uri); $categories = json_decode($response->getBody(), true); // var_dump($categories); foreach ($categories as $category_key => $category_value) { $category = Categories::find($category_value['id']); if (!$category) { $category = new Categories(); $category['id'] = $category_value['id']; $category['type'] = $category_value['type']; isset($category_value['hierarchy'][0]) ? $category['c1'] = $category_value['hierarchy'][0] : ($category['c1'] = null); isset($category_value['hierarchy'][1]) ? $category['c2'] = $category_value['hierarchy'][1] : ($category['c2'] = null); isset($category_value['hierarchy'][2]) ? $category['c3'] = $category_value['hierarchy'][2] : ($category['c3'] = null); // if(isset($category_value['meta']['location']['city'])) // $category['location_city'] = $category_value['meta']['location']['city']; var_dump($category); $category->save(); // die; } } return view('categories')->with('data', $category); }
public function getDelete($id) { $category = Categories::find($id); if ($category && $category instanceof Categories) { $category->delete(); } return Redirect('admin/categories')->with('success', 'Delete category successfully'); }
public static function products($id) { $category = Categories::find($id); $products = Product::all()->where('category_id', $category->id); return $products; }
public function update(CategoriesRequest $request, $id) { $categories = Categories::find($id)->update($request->all()); return redirect()->route('categories'); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Categories::find($id); $category->delete(); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $category = Categories::find($id); $category->delete(); return \Redirect::route('category.index')->with('message', 'Task deleted!'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(Request $request) { $category_id = $request->input('category_id'); $category = Categories::find($category_id); if ($category && $request->user()->is_admin()) { $title = $request->input('title'); $slug = str_slug($title); $duplicate = Categories::where('slug', $slug)->first(); if ($duplicate) { if ($duplicate->id != $category_id) { return redirect('category/edit/' . $category->slug)->withErrors('Title already exists.')->withInput(); } else { $category->slug = $slug; } } $category->title = $title; $category->description = $request->input('description'); $message = 'Post updated successfully'; $landing = $category->slug; $category->save(); $category->slug = str_slug($category->title); $category->save(); return redirect('/category/edit/' . $landing)->withMessage($message); } }
public function getContentByCatID(Request $request, $cat_id) { $page_id = $request->get('p'); $catObj = Categories::find($cat_id); $data['cat_name'] = $catObj->cat_name; $data['fullContent'] = Contents::getCatgoryFullContentByPageID($cat_id, 1); return View::make('catview', $data); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { $category = Categories::find($id); return view('categories.show'); }
public function delete($id) { $categories = Categories::find($id); $categories->delete(); return redirect()->intended('categories'); }