当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::where方法代码示例

本文整理汇总了PHP中Category::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::where方法的具体用法?PHP Category::where怎么用?PHP Category::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     dd('test');
     $vehicleTypes = VehicleTypeRef::all();
     Category::where('id', '>', 58)->whereNull('parent_id')->get()->each(function ($category) use($vehicleTypes) {
         $category->categories->each(function ($subCategory) use($category, $vehicleTypes) {
             //				$vehicleTypes->each(function ($vehicleType) use($category, $subCategory) {
             //					if ($subCategory->title != "{$vehicleType->ru} {$category->name}") {
             $subCategory->description = "Все об {$subCategory->title}";
             //					} else {
             //						 different description
             //					}
             //				});
             if ($subCategory->save()) {
                 $this->line($subCategory->title);
                 $this->line($subCategory->description . PHP_EOL);
             }
         });
     });
     $marks = MarkRef::all();
     Category::where('id', '>', 58)->whereNotNull('parent_id')->get()->each(function ($category) use($vehicleTypes, $marks) {
         $marks->each(function ($mark) use($category, $vehicleTypes) {
             $vehicleTypes->each(function ($vehicleType) use($category, $mark) {
                 if ($category->title == "{$vehicleType->ru} {$mark->name}") {
                     $newTitle = $this->morph($vehicleType) . $mark->name;
                     $this->line("{$category->title} to {$newTitle}");
                     // $category->title = $newTitle;
                     // $category->save();
                 }
             });
         });
     });
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:38,代码来源:CategoriesDescription.php

示例2: index

 /**
  * Display a listing of categories
  *
  * @return Response
  */
 public function index()
 {
     $data = Input::all();
     $categories = Category::where(function ($query) {
         if (Input::has('owner_type')) {
             $query->where('owner_type', Input::get('owner_type'));
         }
         if (Input::has('query')) {
             $query->where('name', 'like', '%' . Input::get('query') . '%');
         }
     });
     $types = Category::get(['owner_type']);
     $types = $types->groupBy(function ($category) {
         return $category->owner_type;
     })->toArray();
     if (Request::ajax()) {
         // SUGGESTIONS FOR AUTOCOMPLETE
         $categories = $categories->get();
         if (Input::has('query')) {
             $suggestions = array();
             foreach ($categories as $category) {
                 $suggestions[] = array("value" => $category->name, "data" => array('owner_type' => $category->owner_type));
             }
             $categories = array('suggestions' => $suggestions);
             return Response::json($categories);
         }
         // RETURN INDEX PANEL
         return View::make('categories.panels.index', compact('categories', 'types'));
     } else {
         $categories = $categories->paginate(Input::get('paginate', 10));
         return View::make('categories.index', compact('categories', 'types'));
     }
 }
开发者ID:waldenylson,项目名称:alfredapp,代码行数:38,代码来源:CategoriesController.php

示例3: Category

 function inc_left()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'knowledges' and parents <> 0")->order_by('orderlist', 'asc')->get();
     $data['count'] = $categories->where("module = 'knowledges' and parents <> 0")->count();
     $data['num'] = ceil($categories->where("module = 'knowledges' and parents <> 0")->count() / 2);
     $this->load->view('inc_index', $data);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:8,代码来源:knowledges.php

示例4: show

 /**
  * Display the specified category.
  *
  * @param  string $slug
  * @return Response
  */
 public function show($slug)
 {
     //return le slug de la categorie
     $categories = Category::where('slug', $slug)->firstOrFail();
     $posts = Post::where('category_id', '=', $categories->id)->orderBy('published_at', 'desc')->paginate(5);
     return View::make('categories.show', compact('categories', 'posts', 'author'));
 }
开发者ID:uknowcreation,项目名称:laravelblog,代码行数:13,代码来源:CategoriesController.php

示例5: edit

 public function edit($id)
 {
     if (Request::isMethod('post')) {
         $rules = array('title' => 'required|min:4', 'link' => 'required', 'meta_keywords' => 'required');
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to("admin/category/{$id}/edit")->withErrors($validator)->withInput(Input::except(''));
         } else {
             $table = Category::find($id);
             $table->title = Input::get('title');
             $table->link = Input::get('link');
             $table->content = Input::get('content');
             $table->parent_id = Input::get('parent_id') ? Input::get('parent_id') : null;
             $table->meta_title = Input::get('meta_title') ? Input::get('meta_title') : $table->title;
             $table->meta_description = Input::get('meta_description') ? Input::get('meta_description') : $table->description;
             $table->meta_keywords = Input::get('meta_keywords');
             $table->active = Input::get('active', 0);
             if ($table->save()) {
                 $name = trans("name.category");
                 return Redirect::to("admin/category")->with('success', trans("message.edit", ['name' => $name]));
             }
             return Redirect::to("admin/category")->with('error', trans('message.error'));
         }
     }
     $self = Category::where('id', '=', $id)->first();
     foreach (Category::lists('title', 'id') as $key => $value) {
         $child = Category::where('id', '=', $key)->first();
         if (!$child->isSelfOrDescendantOf($self)) {
             $categories[$key] = $value;
         }
     }
     $categories = array(0 => 'Нет родительской категории') + $categories;
     return View::make("admin.shop.category.edit", ['item' => Category::find($id), 'categories' => $categories]);
 }
开发者ID:Rotron,项目名称:shop,代码行数:34,代码来源:AdminCategoryController.php

示例6: category

 /**
  * Category list
  * @return Respanse
  */
 public function category($category_id)
 {
     $articles = Article::where('category_id', $category_id)->orderBy('created_at', 'desc')->where('post_status', 'open')->paginate(6);
     $categories = Category::orderBy('sort_order')->get();
     $current_category = Category::where('id', $category_id)->first();
     return View::make('article.category')->with(compact('articles', 'categories', 'category_id', 'current_category'));
 }
开发者ID:rimshavbase,项目名称:timefragment,代码行数:11,代码来源:ArticleController.php

示例7: showIndex

 public function showIndex()
 {
     if (!Auth::check()) {
         return View::make('login', array('title' => 'edison'));
     }
     $category_names = array('ent' => 'エンターテイメント', 'music' => '音楽', 'sing' => '歌ってみた', 'play' => '演奏してみた', 'dance' => '踊ってみた', 'vocaloid' => 'VOCALOID', 'nicoindies' => 'ニコニコインディーズ', 'animal' => '動物', 'cooking' => '料理', 'nature' => '自然', 'travel' => '旅行', 'sport' => 'スポーツ', 'lecture' => 'ニコニコ動画講座', 'drive' => '車載動画', 'history' => '歴史', 'politics' => '政治', 'science' => '科学', 'tech' => 'ニコニコ技術部', 'handcraft' => 'ニコニコ手芸部', 'make' => '作ってみた', 'anime' => 'アニメ', 'game' => 'ゲーム', 'toho' => '東方', 'imas' => 'アイドルマスター', 'radio' => 'ラジオ', 'draw' => '描いてみた', 'are' => '例のアレ', 'diary' => '日記', 'other' => 'その他', 'r18' => 'R-18', 'original' => 'オリジナル', 'portrait' => '似顔絵', 'character' => 'キャラクター');
     $all_items = Item::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($all_items as &$item) {
         $item['user'] = User::where('id', '=', $item->user_id)->get()[0];
         $item['star_count'] = Starmap::where('item_id', '=', $item->id)->count();
         $item['comment_count'] = Comment::where('item_id', '=', $item->id)->count();
         if ($item->category_id != 0) {
             $item['category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $recent_works = Work::orderBy('created_at', 'desc')->take(10)->get();
     foreach ($recent_works as &$work) {
         $item = Item::where('id', '=', $work->item_id)->get()[0];
         $work['item'] = $item;
         $work['user'] = User::where('id', '=', $work->user_id)->get()[0];
         $work['item_poster_screen_name'] = User::where('id', '=', $item->user_id)->get()[0]->screen_name;
         if ($item->category_id != 0) {
             $work['item_category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
         }
     }
     $user = User::where('screen_name', '=', Auth::user()->screen_name)->get()[0];
     $data = array('title' => 'edison', 'user' => $user, 'all_items' => $all_items, 'recent_works' => $recent_works, 'categories' => $category_names, 'star_count' => Starmap::where('user_id', '=', $user->id)->count(), 'work_count' => Work::where('user_id', '=', Auth::user()->id)->count());
     return View::make('index', $data);
 }
开发者ID:return-zero,项目名称:ma9,代码行数:29,代码来源:HomeController.php

示例8: index

 function index()
 {
     $categories = new Category();
     $data['categories'] = $categories->where("module = 'webboard_quizs' and parents <> 0")->order_by('orderlist', 'asc')->get_page();
     $data['categories']->webboard_quiz->order_by("id", "desc")->get();
     $this->template->build('webboard_index', $data);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:7,代码来源:webboards.php

示例9: store

 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store()
 {
     $categoryValidator = Validator::make($data = Input::all(), Category::$rules);
     if ($categoryValidator->fails()) {
         return Redirect::back()->withErrors($categoryValidator)->withInput();
     }
     /* Category */
     if (Input::has('createCategory')) {
         Category::create($data);
         $message = "登録しました。";
     }
     if (Input::has('deleteCategory')) {
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $message = "削除しました。";
         if (Input::has('selectedCategory')) {
             Input::replace(array('selectedCategory', ''));
         }
     }
     if (Input::has('updateCategory')) {
         $err = array('required' => '新しい部門名を入力してください。');
         $categoryValidator = Validator::make($data = Input::all(), Category::$update_rules, $err);
         if ($categoryValidator->fails()) {
             return Redirect::back()->withErrors($categoryValidator)->withInput();
         }
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $data['Bumon'] = $data['new_categoryName'];
         Category::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
开发者ID:noikiy,项目名称:posco-laravel-server,代码行数:38,代码来源:CategoriesController.php

示例10: getTorrents

 public function getTorrents($category = null)
 {
     $categories = Category::all();
     $query = Torrent::with('category')->orderBy('created_at', 'desc');
     if ($category) {
         $category = Category::where('name', '=', $category)->first();
         if ($category) {
             $query = $query->where('category_id', $category->id);
         }
     }
     $search = null;
     if (isset($_GET['text'])) {
         $search = $_GET['text'];
         $query = $query->where('name', 'LIKE', '%' . $search . '%');
     }
     $torrents = $query->get();
     $peers = DB::table('torrent_users')->select(DB::raw('torrent_id, seeding, COUNT(user_id) as count'))->groupBy('torrent_id', 'seeding')->get();
     foreach ($peers as $peer) {
         foreach ($torrents as $torrent) {
             if ($torrent->id == $peer->torrent_id) {
                 if ($peer->seeding) {
                     $torrent->seeders = $peer->count;
                 } else {
                     $torrent->leechers = $peer->count;
                 }
             }
         }
     }
     return View::make('torrents/torrents', array('torrents' => $torrents, 'categories' => $categories, 'category' => $category, 'search' => $search));
 }
开发者ID:ne0lite,项目名称:Tracker,代码行数:30,代码来源:TorrentController.php

示例11: produce

 /**
  * Produce new products
  *
  * @return Response
  */
 public function produce()
 {
     $category_id = Category::where('cat_name', '=', 'Cupcake')->first()->id;
     $items = $this->item->where('category_id', '=', $category_id)->get();
     // return $items = $this->item->getItemsWithInventoryStatus();
     return View::make('items.production.produce')->with('title', 'New Production')->with('items', $items);
 }
开发者ID:fagray,项目名称:fposs,代码行数:12,代码来源:ProductionController.php

示例12: edit

 /**
  * Show the form for editing the specified resource.
  * GET /articles/{id}/edit
  *
  * @param  string $slug
  * @return Response
  */
 public function edit($slug)
 {
     $articles = Article::where('slug', $slug)->first();
     $category = Category::lists('category', 'id');
     $selected = Category::where('id', $articles->category_id)->first()->id;
     return View::make('article.editpost')->with('articles', $articles)->with('category', $category)->with('selected', $selected);
 }
开发者ID:tprifti,项目名称:Blog,代码行数:14,代码来源:ArticlesController.php

示例13: index

 function index()
 {
     $rs = new Category();
     $data['rs'] = $rs->where('module = "services"')->order_by('id', 'desc')->get();
     $this->template->append_metadata(js_checkbox('approve'));
     $this->template->build('admin/index', $data);
 }
开发者ID:unisexx,项目名称:imac,代码行数:7,代码来源:services.php

示例14: setupLayout

 protected function setupLayout()
 {
     if (!is_null($this->layout)) {
         $this->layout = View::make($this->layout);
         $this->layout->menuCategories = Category::where('parent_id', 0)->get();
     }
 }
开发者ID:leoxopow,项目名称:dmtoys,代码行数:7,代码来源:BaseController.php

示例15: get_list

 public function get_list($id = 0)
 {
     $breadcrumbs = Breadcrumbs::get($id);
     $categories = $id ? Category::find($id)->children : Category::where('parent', '=', 0)->get();
     $products = $id ? Category::find($id)->products : array();
     $this->layout->page_title = "Admin - Categories - List";
     $this->layout->page_content = View::make('admin.categories.list')->with('id', $id)->with('breadcrumbs', $breadcrumbs)->with('categories', $categories)->with('products', $products);
 }
开发者ID:robmeijer,项目名称:seer,代码行数:8,代码来源:categories.php


注:本文中的Category::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。