コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: CategoriesController.php プロジェクト: jither7/vcar
 public function getDelete($id)
 {
     $category = Categories::find($id);
     if ($category && $category instanceof Categories) {
         $category->delete();
     }
     return Redirect('admin/categories')->with('success', 'Delete category successfully');
 }
コード例 #3
0
ファイル: Categories.php プロジェクト: karlos545/Aydins
 public static function products($id)
 {
     $category = Categories::find($id);
     $products = Product::all()->where('category_id', $category->id);
     return $products;
 }
コード例 #4
0
 public function update(CategoriesRequest $request, $id)
 {
     $categories = Categories::find($id)->update($request->all());
     return redirect()->route('categories');
 }
コード例 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $category = Categories::find($id);
     $category->delete();
 }
コード例 #6
0
 /**
  * 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!');
 }
コード例 #7
0
 /**
  * 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);
     }
 }
コード例 #8
0
 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);
 }
コード例 #9
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $category = Categories::find($id);
     return view('categories.show');
 }
コード例 #10
0
 public function delete($id)
 {
     $categories = Categories::find($id);
     $categories->delete();
     return redirect()->intended('categories');
 }