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


PHP Category::with方法代碼示例

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


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

示例1: viewCategories

 public static function viewCategories($request)
 {
     $categories = Category::with(['devices'])->latest('updated_at');
     $categories = $categories->where('name', 'LIKE', '%' . $request->get('filter') . '%')->paginate(25);
     $categories->setPath('/');
     return view('home', compact('categories'));
 }
開發者ID:encry2024,項目名稱:inv_5_2,代碼行數:7,代碼來源:Category.php

示例2: index

 /**
  * Retrieve all categories with their products
  * Products can have a category_id_sub : if it is not null, a category with sub_ids can be shown on screen
  *
  * @return mixed
  */
 public function index()
 {
     return Category::with(['products' => function ($q) {
         $q->select(['products.id', 'category_id', 'name', 'price', 'visible', 'sort', 'category_id_sub']);
         $q->orderBy('sort');
     }])->orderBy('sort')->get();
 }
開發者ID:KassaKiosk,項目名稱:management,代碼行數:13,代碼來源:ProductsController.php

示例3: getAll

 /**
  * Get all categories with childs ordered by priority
  *
  * @return collection
  */
 public static function getAll()
 {
     $categories = Category::with(['childs' => function ($query) {
         $query->orderBy('priority', 'desc');
     }])->where('parent_id', null)->orderBy('priority')->get();
     return $categories;
 }
開發者ID:elberd,項目名稱:maoh,代碼行數:12,代碼來源:Category.php

示例4: showSingleCategory

 /**
  * @param $slug
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showSingleCategory($slug)
 {
     $categories = Category::with('products')->where('is_active', true)->has('products')->get();
     $category = Category::findBySlug($slug);
     $products = $category->products;
     return view('frontend.categories.showCategory', compact('categories', 'category', 'products'));
 }
開發者ID:Reached,項目名稱:webshop,代碼行數:11,代碼來源:CategoriesController.php

示例5: destroy

 public function destroy(Request $request)
 {
     $model = Category::with('articles', 'announcements')->find($request->id);
     if (empty($model)) {
         Flash::error('Impossible de supprimer cette catégorie.');
         return Redirect::back();
     }
     $announcements = $model->announcements();
     $articles = $model->articles();
     if (!empty($announcements)) {
         foreach ($announcements as $a) {
             $a->update(['category_id' => 1]);
         }
     }
     if (!empty($articles)) {
         foreach ($articles as $a) {
             $a->update(['category_id' => 1]);
         }
     }
     $name = $model->name;
     $model->delete();
     makeModification('categories', 'The category « ' . $name . ' » has been removed.');
     Flash::success('La catégorie a bien été supprimé.');
     return Redirect::back();
 }
開發者ID:Techraav,項目名稱:PolyMusic,代碼行數:25,代碼來源:CategoryController.php

示例6: updatePostCount

 private static function updatePostCount()
 {
     foreach (Category::with('posts')->get() as $category) {
         $category->post_count = $category->posts()->count();
         $category->save();
     }
 }
開發者ID:shempignon,項目名稱:laravel-5-blog-mvc,代碼行數:7,代碼來源:PostServiceProvider.php

示例7: viewMenus

 public function viewMenus($id = '')
 {
     $categories = Category::with('product')->lightSelection()->store()->full()->orderBy('name')->get()->toArray();
     $actualCategory = [];
     findfather($actualCategory, $categories, $id);
     $panel = ['left' => ['width' => '3', 'class' => 'categories-panel'], 'center' => ['width' => '9']];
     return view('categories.menus', ['panel' => $panel, 'categories' => orderByParents($categories), 'actualCategory' => $actualCategory]);
 }
開發者ID:softsolution,項目名稱:antVel,代碼行數:8,代碼來源:CategoriesController.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $record = Category::with('user')->get();
     if (!$record) {
         return View::make('errors.404');
     }
     //return View::make('company_category.index')->with('data', $record);
     return View::make('company_category.index', ['data' => $record, 'categories' => $this->getCategoryListAsJson()]);
 }
開發者ID:retnan,項目名稱:bir,代碼行數:14,代碼來源:CompanyCategoryController.php

示例9: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $categories = Category::with(['threads' => function ($query) {
         $query->orderBy('updated_at', 'desc');
     }, 'threads.posts' => function ($query) {
         $query->orderBy('created_at', 'asc');
     }, 'threads.posts.user'])->get();
     return view('categories.index', compact('categories'));
 }
開發者ID:Kehet,項目名稱:k-forum,代碼行數:14,代碼來源:CategoriesController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @param $categoryId
  * @return Response
  */
 public function index($categoryId)
 {
     $category = Category::with(['threads' => function ($query) {
         $query->orderBy('updated_at', 'desc');
     }, 'threads.posts' => function ($query) {
         $query->orderBy('created_at', 'asc');
     }, 'threads.posts.user'])->findOrFail($categoryId);
     return view('threads.index', compact('category'));
 }
開發者ID:Kehet,項目名稱:k-forum,代碼行數:15,代碼來源:ThreadsController.php

示例11: getIndex

 /**
  * Отображает список категорий.
  *
  * @return Response
  */
 public function getIndex()
 {
     // Ищем фирму по короткому названию
     $data['company'] = Company::whereShortTitle($this->companyName)->first();
     // Получаем список групп категорий
     $data['categories'] = Category::with('group_category')->with('parent_category')->whereHas('group_category', function ($query) use($data) {
         $query->where('company_id', '=', $data['company']->id);
     })->get();
     return view('admin.companies.catalog.categories.index', $data);
 }
開發者ID:alexmon1989,項目名稱:kadsgroup,代碼行數:15,代碼來源:CategoriesController.php

示例12: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     $category = Category::with(['threads', 'threads.posts'])->findOrFail($id);
     foreach ($category->threads as $thread) {
         $thread->posts()->delete();
     }
     $category->threads()->delete();
     $category->delete();
     return redirect()->route('admin.categories.index');
 }
開發者ID:Kehet,項目名稱:k-forum,代碼行數:16,代碼來源:AdminCategoriesController.php

示例13: getCategoriesAdmin

 public function getCategoriesAdmin($departmentId = null)
 {
     if ($departmentId) {
         $categories = Category::with('langs')->where('department_id', $departmentId)->sort()->get();
     } else {
         $categories = Category::with('langs')->sort()->get();
     }
     $categories = $this->loadLangs($categories);
     return $categories;
 }
開發者ID:Tisho84,項目名稱:conference,代碼行數:10,代碼來源:ConferenceBaseController.php

示例14: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = new Users();
     $user->fill($request->all());
     $user->password = Hash::make($request->input('password'));
     $user->save();
     $data['partner'] = Partner::orderBy('created_at', 'asc')->get();
     $data['category'] = Category::with('SubCategory')->orderBy('created_at', 'asc')->get();
     return view('site.success', $data);
 }
開發者ID:nikajorjika,項目名稱:gamoiwere.ge,代碼行數:16,代碼來源:UserController.php

示例15: getRooms

 public static function getRooms($q)
 {
     $json = array();
     $categories = Category::with(['rooms' => function ($query) use($q) {
         $query->where('name', 'LIKE', '%' . $q . '%');
     }])->get();
     foreach ($categories as $category) {
         foreach ($category->rooms as $room) {
             $json[] = ['category_id' => $category->id, 'room_id' => $room->id, 'category_name' => $category->name, 'room_name' => $room->name, 'category_min' => $category->min_capacity, 'category_max' => $category->max_capacity, 'category_price' => $category->price];
         }
     }
     return $json;
 }
開發者ID:encry2024,項目名稱:overlook,代碼行數:13,代碼來源:Room.php


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