當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::find方法代碼示例

本文整理匯總了PHP中app\Category::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::find方法的具體用法?PHP Category::find怎麽用?PHP Category::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app\Category的用法示例。


在下文中一共展示了Category::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: category

 /**
  * Show all products by category id.
  *
  * @param $id
  * @return \Illuminate\View\View
  */
 public function category($id)
 {
     $categories = $this->category->orderBy('name')->get();
     $products = $this->product->where('category_id', '=', $id)->paginate(8);
     $categoryName = $this->category->find($id)->name;
     return view('ecomm.shop.partial.products-category', compact('categories', 'products', 'categoryName'));
 }
開發者ID:JimiOhrid,項目名稱:shopStore,代碼行數:13,代碼來源:StoreController.php

示例2: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $job_id = $id;
     $job_info = Job::find($job_id);
     $job_category_info = JobCategory::where('job_id', '=', $job_id)->get();
     $category_array = array();
     foreach ($job_category_info as $a_job_category) {
         $a_category_id = $a_job_category->category_id;
         $a_category_value = Category::find($a_category_id)->kategori;
         $category_array[count($category_array)] = $a_category_value;
     }
     $data['job_info'] = $job_info;
     $data['category_array'] = $category_array;
     // find out whether the logged-in user have already request this job (as a seeker)
     // if the owner of this job is the logged-in user, then don't show the request button
     $show_request_button = true;
     $this_is_the_owner = false;
     if (Auth::user() != null) {
         $logged_user_id = Auth::user()->id;
         if ($job_info->freelancer_info_id == $logged_user_id) {
             // if the owner of this job is the logged-in user
             $show_request_button = false;
             $this_is_the_owner = true;
         } else {
             // if logged-in user already request this job (as a seeker)
             if (JobRequest::find($job_id, $logged_user_id) != null) {
                 $show_request_button = false;
             }
         }
     } else {
         //if guest (not logged-in user)
     }
     return View::make('job.show')->with('data', $data)->with('jobs', $job_info)->with('job_id', $id)->with('show_request_button', $show_request_button)->with('this_is_the_owner', $this_is_the_owner);
 }
開發者ID:sagaekakristi,項目名稱:ppla02,代碼行數:40,代碼來源:JobPageController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $category = Category::find($id);
     $category->name = $request->name;
     $category->save();
     return redirect()->route('category.index');
 }
開發者ID:pedja260,項目名稱:pedagoska_sveska,代碼行數:14,代碼來源:CategoryController.php

示例4: browseCategory

 /**
  * Show user receipts of a specific Category.
  *
  * @param  int  $id
  * @return Response
  */
 public function browseCategory($id)
 {
     $receipts = Receipt::whereHas('categories', function ($query) use($id) {
         $query->where('id', '=', $id);
     })->where('user_id', '=', $this->user->id)->paginate();
     return view('pages.receipts', compact('receipts'))->with('page_title', Category::find($id)->name);
 }
開發者ID:hootlex,項目名稱:apodeiksi,代碼行數:13,代碼來源:PagesController.php

示例5: deactivate

 public function deactivate($id)
 {
     $category = Category::find($id);
     $category->status = 0;
     $category->save();
     return redirect('home/categories');
 }
開發者ID:bigDeacs,項目名稱:bunbury,代碼行數:7,代碼來源:CategoriesController.php

示例6: showByUser

 public function showByUser($user_id)
 {
     //directly copied pasted from list controller.
     $list = Vote::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-200x200.' . $initial[sizeof($initial) - 1];
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return $user_list;
     //        return response()->json([
     //                'upvotted'=>$user_list]
     //        );
 }
開發者ID:ShehabSunny,項目名稱:ProductZap,代碼行數:30,代碼來源:VotesController.php

示例7: categories

 public function categories()
 {
     $view = Input::get('view');
     if ($view == null) {
         return redirect('/admin/categories?view=hierarchy');
     }
     $levels = ['Main Category', 'Subcategory', 'Post Sub Category'];
     $types = ['main-categories', 'sub-categories', 'post-sub-categories'];
     $views = ['Hierarchy', 'Type', 'All'];
     $cats = Category::roots()->get();
     $category = Input::get('category');
     $_category = Category::find($category);
     if ($view == 'type') {
         $type = Input::get('type');
         if ($type == null) {
             $type = $types[0];
         }
         // array_keys() = get keys from value
         // appends() = add 'get' variables (to url)
         $cats = Category::whereDepth(array_keys($types, $type))->paginate(25)->appends(Input::except('page'));
     } else {
         if ($view == 'all') {
             $cats = Category::paginate(25)->appends(Input::except('page'));
         }
     }
     return view('admin.main')->with('category', $_category)->with('cats', $cats)->with('levels', $levels)->with('view', $view)->with('views', $views)->with('types', $types);
     // only for 'type' view
 }
開發者ID:bluecipherz,項目名稱:gl-ct,代碼行數:28,代碼來源:AdminPanelController.php

示例8: store

 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|max:100', 'model' => 'max:100', 'category_id' => 'required|array', 'photo' => 'image|max:2048']);
     if (!$validator->fails()) {
         $categories_id = $request->input('category_id');
         $catTitles = "";
         // add title and comma for success message
         foreach ($categories_id as $index => $id) {
             $catTitles .= Category::find($id)->title;
             if ($index + 1 != count($categories_id)) {
                 $catTitles .= ", ";
             }
         }
         $product = Product::create(['name' => $request->input('name'), 'model' => $request->input('model')]);
         $product->categories()->attach($categories_id);
         if ($request->hasFile('photo')) {
             $uploaded_photo = $request->file('photo');
             $extension = $uploaded_photo->getClientOriginalExtension();
             $filename = md5(time()) . '.' . $extension;
             $destinationPath = public_path('img');
             $uploaded_photo->move($destinationPath, $filename);
         }
         $product->photo = $filename;
         $product->save();
         return redirect('products')->with('successMsg', $request->input('name') . ' has been successfully created under : ' . $catTitles);
     } else {
         return redirect()->back()->withErrors($validator)->withInput();
     }
 }
開發者ID:yevta,項目名稱:laravel-catalog,代碼行數:29,代碼來源:ProductController.php

示例9: index

 public function index()
 {
     $updates = new Update();
     $category = Category::find(4);
     $now = Carbon::now();
     return view('about.galleries.index', compact('updates', 'now', 'category'));
 }
開發者ID:academies-trust,項目名稱:poundhill,代碼行數:7,代碼來源:GalleryController.php

示例10: destroy

 /**
  * Destroy the given category.
  *
  * @param  Request  $request
  * @param  string  $categoryId
  * @return Response
  */
 public function destroy(Request $request, $categoryId)
 {
     $category = Category::find($categoryId);
     $this->authorize('destroy', $category);
     $category->destroy($categoryId);
     return redirect('/categories');
 }
開發者ID:vaiveg,項目名稱:vaiva-blog,代碼行數:14,代碼來源:CategoryController.php

示例11: edit

 public function edit($id, $extra = array())
 {
     $category = \App\Category::find($id);
     $extra['parents'] = array_filter($this->getParents($category));
     $extra['selectedParentId'] = $id;
     return parent::edit($id, $extra);
 }
開發者ID:stjanilofts,項目名稱:gicms,代碼行數:7,代碼來源:CategoryController.php

示例12: razredi

 public function razredi($id)
 {
     $category = Category::find($id);
     $students = Student::where('category_id', '=', $category->id)->get();
     //return $category;
     return view('reports.razred')->with('category->id', $category->id)->with('students', $students)->with('category', $category);
 }
開發者ID:pedja260,項目名稱:pedagoska_sveska,代碼行數:7,代碼來源:ReportController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     // Topic
     $topicCategorys = ['Talk', 'Party', 'Movie', 'Music', 'Goods', 'Sport', 'Game'];
     foreach ($topicCategorys as $index => $category) {
         Category::create(['name' => $category, 'type_id' => Category::TYPE_TOPIC]);
     }
     // children Topic
     $topicCategorys = Category::where('type_id', '=', Category::TYPE_TOPIC)->lists('id')->toArray();
     foreach (range(1, 20) as $index) {
         $parentId = $faker->randomElement($topicCategorys);
         $name = Category::find($parentId)->name;
         Category::create(['name' => $name . $index, 'type_id' => Category::TYPE_TOPIC, 'parent_id' => $parentId]);
     }
     // Article
     $articleCategorys = ['Hot News', 'BeiJing', 'China', 'America', 'England'];
     foreach ($articleCategorys as $index => $category) {
         Category::create(['name' => $category, 'type_id' => Category::TYPE_ARTICLE]);
     }
     // Blog
     $blogCategorys = ['Uncategory', 'Log', 'Heavy'];
     foreach ($blogCategorys as $index => $category) {
         Category::create(['name' => $category, 'type_id' => Category::TYPE_BLOG]);
     }
 }
開發者ID:jvlstudio,項目名稱:3N1WebSite,代碼行數:31,代碼來源:CategoryTableSeeder.php

示例14: show_for_other_user

 public function show_for_other_user($user_id)
 {
     $list = Lists::where('user_id', '=', $user_id)->get();
     $user_list = [];
     foreach ($list as $pro) {
         $product_id = $pro->product_id;
         $product = Product::find($product_id);
         if ($product != null) {
             $created_by = $product['created_by'];
             $category = Category::find($product['category_id']);
             $category = $category['category'];
             $user = User::find($created_by);
             array_add($product, 'category', $category);
             array_add($product, 'created_by_name', $user['name']);
             $initial = explode(".", $product['image_url']);
             $thumbFirst = "";
             for ($i = 0; $i < sizeof($initial) - 1; $i++) {
                 $thumbFirst = $thumbFirst . $initial[$i];
             }
             $thumbnail = $thumbFirst . '-130x90.' . $initial[sizeof($initial) - 1];
             //thumb size changed
             array_add($product, 'thumbnail', $thumbnail);
             array_push($user_list, $product);
         }
     }
     return response()->json(['list' => $user_list]);
 }
開發者ID:ShehabSunny,項目名稱:ProductZap,代碼行數:27,代碼來源:ListController.php

示例15: updateCategory

 public function updateCategory(Request $request, $id)
 {
     $Category = Category::find($id);
     $Category->name = $request->input('name');
     $Category->save();
     return response()->json($Category);
 }
開發者ID:rafix82,項目名稱:rssmonster,代碼行數:7,代碼來源:CategoryController.php


注:本文中的app\Category::find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。