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


PHP Category::where方法代码示例

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


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

示例1: delete_category_by_parent_id

 public function delete_category_by_parent_id($id)
 {
     if (Category::where("parent_id", "=", $id)->delete()) {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:Incubasys,项目名称:sql_query_help,代码行数:7,代码来源:Category.php

示例2: run

 public function run()
 {
     $woodworking = App\Category::where('name', 'Woodworking')->first();
     $woodworking->skills()->create(['name' => 'Carpentry', 'description' => 'Making or repairing things in wood', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Table Saw', 'description' => 'Using and maintaining a table saw', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Bandsaw', 'description' => 'Using and maintaining a band saw', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Lathe', 'description' => 'Using and maintaining a lathe', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $woodworking->skills()->create(['name' => 'Bandsaw Box', 'description' => 'Making a bandsaw box', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $digital = App\Category::where('name', 'Digital Fabrication')->first();
     $digital->skills()->create(['name' => '3D printing', 'description' => 'Repair and use of 3D printers', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $digital->skills()->create(['name' => 'Laser Cutter', 'description' => 'Use and maintainence of laser cutters', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics = App\Category::where('name', 'Electronics')->first();
     $electronics->skills()->create(['name' => 'PCB Making', 'description' => 'Making printed circuit boards', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Embedded Programming', 'description' => 'programming embedded systems', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Soldering', 'description' => 'Soldering', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $electronics->skills()->create(['name' => 'Robotics', 'description' => 'Making robots', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $technology = App\Category::where('name', 'Technology')->first();
     $technology->skills()->create(['name' => 'Web Programming', 'description' => 'Programming for the web', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $technology->skills()->create(['name' => 'PC Building', 'description' => 'Building PCs from components', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $arts = App\Category::where('name', 'Arts')->first();
     $arts->skills()->create(['name' => 'Fabrics', 'description' => 'Fabrics', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $arts->skills()->create(['name' => 'Photography', 'description' => 'Photography', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $science = App\Category::where('name', 'Science')->first();
     $science->skills()->create(['name' => 'Nutrition', 'description' => 'Basic Nutrition', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
     $science->skills()->create(['name' => 'Science?', 'description' => 'Is this even a valid category?', 'created_by_id' => 1, 'approved' => true, 'approved_by_id' => 1]);
 }
开发者ID:Ranthalion,项目名称:LevelUp,代码行数:26,代码来源:SkillsTableSeeder.php

示例3: index

 public function index($slug)
 {
     LaravelGettext::setLocale('bg_BG');
     $category = Category::where('slug', $slug)->first();
     $products = Product::where('categories_id', $category->id)->get();
     return view('category.index', compact('products', 'category'));
 }
开发者ID:sbrojdenov,项目名称:shop,代码行数:7,代码来源:5abe78a3d49f4dbedb9f6571570c17970f2e04dc.php.php

示例4: show

 public function show($title)
 {
     $category = \App\Category::where('title', '=', $title)->first();
     // dd($category->books());
     $books = $category->books()->get();
     return view('category.category', compact('category', 'books'));
 }
开发者ID:aleximillers,项目名称:estore-laravel-angular,代码行数:7,代码来源:CategoryController.php

示例5: getArticle

 public function getArticle($cate, $arti)
 {
     $arti = substr($arti, 0, -5);
     //cắt chuối ".html" cuối article alias
     $category = Category::where("category_alias", $cate)->first();
     //lấy category đầu tiên có alias bằng tham số category alias
     $listCategory = Category::all(["id", "category_alias", "category_name"])->toArray();
     $allArticles = Article::all(["id", "title", "alias", "summary", "content", "image", "category_id", "author", "created_date"])->where('category_id', $category["id"])->toArray();
     //lấy tất cả bài viết trong category
     if ($category != null) {
         $message = "";
         $category_name = $category["category_name"];
         if (count($allArticles) == 0) {
             $message = 'Không có bài viết nào.';
         } else {
             $article = Article::where("alias", $arti)->first();
             if ($article != null) {
                 $relateArticles = Article::where('category_id', $category["id"])->where("id", '!=', $article["id"])->orderBy('created_date', 'desc')->get()->take(2)->toArray();
                 return view('front.blog.article', compact('listCategory', 'relateArticles', 'message', 'category_name', 'article', 'mess'));
             } else {
                 $message = "Không tìm thấy bài viết phù hợp";
                 return view('front.blog.error', compact('listCategory', 'message', 'category_name'));
             }
         }
         return view('blog.index', compact('listCategory', 'message', 'category_name'));
     }
 }
开发者ID:quangtruong16994,项目名称:laravel,代码行数:27,代码来源:BlogController.php

示例6: show

 public function show($slug)
 {
     // Tökum bara síðasta stykkið
     $e = array_filter(explode("/", $slug));
     $last = end($e);
     $item = \App\Category::where('status', 1)->where('slug', $last)->first();
     if ($item) {
         $cats = \App\Category::where('status', 1)->where('parent_id', $item->id)->orderBy('order')->get();
         $prods = \App\Product::where('status', 1)->where('category_id', $item->id)->orderBy('order')->get();
         $data['items'] = $cats->merge($prods);
         $data['pagetitle'] = $item->title;
         $data['seo'] = $item;
         return view('frontend.products')->with($data);
     }
     $item = \App\Product::where('status', 1)->where('slug', $last)->first();
     if (!$item) {
         if (!$item) {
             abort(404, 'Fann ekki síðu!');
         }
     }
     $data['item'] = $item;
     $data['seo'] = $item;
     $data['images'] = $item->img()->all();
     $data['colors'] = $item->skirt()->all();
     $data['image'] = is_array($data['images']) && array_key_exists(0, $data['images']) ? $data['images'][0] : ['name' => $item->img()->first(), 'title' => ''];
     $data['siblings'] = $item->getSiblings();
     $data['pagetitle'] = isset($item->category->title) ? $item->category->title : 'Vörur';
     if ($item->category_id > 1) {
         $data['pagetitle'] = $item->title;
     }
     return view('frontend.product')->with($data);
 }
开发者ID:stjanilofts,项目名称:cp,代码行数:32,代码来源:VorukerfiController.php

示例7: getItem

 public function getItem($item)
 {
     $item = Furnitura::where('sef', $item)->first();
     $category = Category::where('id', $item->category_id)->first();
     // тут я собираю полный путь к текущей категории для ссылки наверх в категорию
     $tocat = array();
     foreach ($category->getAncestors() as $ancestor) {
         array_push($tocat, $ancestor->sef);
     }
     $tocat = implode('/', $tocat);
     // тут я собираю все картинки товара
     $img = array();
     for ($i = 2; $i < 20; $i++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->id . '-big-' . $i . '.jpg')) {
             array_push($img, '/img/furnitura/' . $item->id . '-big-' . $i . '.jpg');
         }
     }
     $dwg = array();
     for ($j = 2; $j < 20; $j++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->artikul . '-dwg-' . $j . '.jpg')) {
             array_push($dwg, '/img/furnitura/' . $item->artikul . '-dwg-' . $j . '.jpg');
         }
     }
     $virez = array();
     for ($k = 2; $k < 20; $k++) {
         if (file_exists(public_path() . '/img/furnitura/' . $item->artikul . '-virez-' . $k . '.jpg')) {
             array_push($virez, '/img/furnitura/' . $item->artikul . '-virez-' . $k . '.jpg');
         }
     }
     $previous = Furnitura::where('No', '<', $item->No)->orderBy('No', 'desc')->first();
     $next = Furnitura::where('No', '>', $item->No)->orderBy('No', 'asc')->first();
     return view('furnitura.item')->withCategory($category)->withItem($item)->withImg($img)->withDwg($dwg)->withVirez($virez)->withPrevious($previous)->withNext($next)->withTocat($tocat);
 }
开发者ID:schel4ok,项目名称:steklo,代码行数:33,代码来源:FurnituraController.php

示例8: store

 public function store($slug)
 {
     $product = Product::where('slug', $slug)->first();
     $category = Category::where('id', $product->categories_id)->first();
     Cart::add(array('id' => $product->id, 'name' => $product->title, 'price' => $product->price, 'quantity' => 1, 'attributes' => array($product->image_url)));
     return redirect(LaravelLocalization::setLocale() . DIRECTORY_SEPARATOR . "category/{$category->slug}")->with('message', 'Продукта е добавен в количката!');
 }
开发者ID:sbrojdenov,项目名称:shop,代码行数:7,代码来源:OrderController.php

示例9: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($name, Request $request)
 {
     $this->validate($request, ['color' => 'required']);
     $category = Category::where('name', $name)->first();
     $category->update($request->all());
     return Redirect("/admin/categories");
 }
开发者ID:elinadenfina,项目名称:lazyNinjaEvents,代码行数:13,代码来源:CategoryController.php

示例10: getCategorybybranch

 public function getCategorybybranch($branch_id)
 {
     $categoriesName = Category::where('branch_id', '=', $branch_id)->get();
     foreach ($categoriesName as $categoryName) {
         echo "<option value = {$categoryName->id} > {$categoryName->name}</option> ";
     }
 }
开发者ID:woakes070048,项目名称:cemcoErp,代码行数:7,代码来源:ProductSubCategoryController.php

示例11: update

 public function update(Request $request, $id)
 {
     $app = App::find($id);
     $app->name = Input::get('name');
     $app->category_id = Category::where('name', '=', Input::get('class_name'))->pluck('id');
     $app->slogan = Input::get('slogan');
     $app->introduce = Input::get('introduce');
     $app->android = Input::get('android');
     $app->ios = Input::get('ios');
     $app->download = Input::get('download');
     $app->is_check = 1;
     //图片处理
     $tmp_name = $_FILES['logo']['tmp_name'];
     if ($tmp_name) {
         $result_pic = $data['logo'] = FileHandler::uploadPic($tmp_name);
         if ($result_pic['success']) {
             $app->logo = $result_pic['name'];
         } else {
             return Redirect::back()->withInput()->withErrors($result_pic['msg']);
         }
     }
     if ($app->save()) {
         return Redirect::back();
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
开发者ID:kevinwan,项目名称:che123,代码行数:27,代码来源:AppController.php

示例12: categoryModify

 public function categoryModify(Request $request, $id)
 {
     $cat_to_mod = Category::where('id', $id)->first();
     $inputs = $request->except('_token', 'button');
     if ($request->button == 'mod') {
         $x = 0;
         foreach ($inputs as $input) {
             if (!empty($input)) {
                 $x = 1;
             }
         }
         if ($x == 0) {
             return redirect('admin');
         }
         if ($request->name) {
             $cat_to_mod->name = $request->name;
         }
         $cat_to_mod->save();
     }
     if ($request->button == 'del') {
         $item_count = Item::where('category_id', $id)->get()->count();
         if ($item_count >= 1) {
             return redirect('admin')->withErrors('Suppression impossible : des produits appartiennent a cette catgorie');
         }
         $cat_to_mod->delete();
         return redirect('admin')->with('status', 'Catégorie supprimée');
     }
     return redirect('admin')->with('status', 'Modifications de la catégorie enregistrées');
 }
开发者ID:starmatt,项目名称:webpapa,代码行数:29,代码来源:AdminCategoryController.php

示例13: home

 public function home()
 {
     //$data['forsidumyndir'] = \App\Page::where('slug', '_forsidumyndir')->first()->getSubs();
     $cats = \App\Category::where('status', 1)->get();
     $prods = \App\Product::where('status', 1)->get();
     $items = [$cats, $prods];
     $kubbar = [];
     foreach ($items as $item) {
         foreach ($item as $v) {
             $frontpaged = trim($v->extras()->get('frontpaged')) ?: 0;
             $size = trim($v->extras()->get('size'));
             $titill = trim($v->extras()->get('titill')) ?: $v->title;
             if ($frontpaged && $frontpaged != 0) {
                 $kubbar[] = ['title' => $titill, 'size' => $size ? $size : 1, 'frontpaged' => $frontpaged, 'fillimage' => $v->fillimage ? true : false, 'path' => $v->fullPath(), 'image' => $v->img()->first(), 'slug' => $v->slug];
             }
         }
     }
     usort($kubbar, function ($a, $b) {
         if ($a['frontpaged'] == $b['frontpaged']) {
             return 0;
         }
         return $a['frontpaged'] < $b['frontpaged'] ? -1 : 1;
     });
     $data['kubbar'] = $kubbar;
     return view('frontend.layout')->with($data);
 }
开发者ID:stjanilofts,项目名称:lh,代码行数:26,代码来源:HomeController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index($idlevel, $level, $idspeciality, $speciality, $idmaterial, $material, $idlesson, $lesson)
 {
     $newsallarticles = Article::where('stat', '=', 'nouvelles')->orderBy('id', 'desc')->take(3)->get();
     $bacallarticles = Article::where('stat', '=', 'apres-bac')->orderBy('id', 'desc')->take(3)->get();
     $speciality = str_replace('-', ' ', $speciality);
     $material = str_replace('-', ' ', $material);
     $lesson = str_replace('-', ' ', $lesson);
     $lessonnames = Lesson::where('id', '=', $idlesson)->get();
     $specialitynames = Category::where('id', '=', $idspeciality)->get();
     $alllessons = Lesson::groupBy('categories_id')->orderBy('id', 'desc')->get();
     $rounds1 = Lesson::where('round', '=', '1ere-session')->get();
     $rounds2 = Lesson::where('round', '=', '2eme-session')->get();
     $fullcat = Category::get();
     $all = Category::where('parent', '=', 0);
     $level = str_replace('-', ' ', $level);
     $levelnames = Category::where('id', '=', $idlevel)->get();
     $materialnames = Category::where('id', '=', $idmaterial)->get();
     foreach ($lessonnames as $lessonname) {
         $ar_lessonname = $lessonname->ar_title;
     }
     foreach ($specialitynames as $specialityname) {
         $ar_specialityname = $specialityname->ar_name;
     }
     foreach ($levelnames as $levelname) {
         $ar_levelname = $levelname->ar_name;
     }
     foreach ($materialnames as $materialname) {
         $ar_materialname = $materialname->ar_name;
     }
     return view(proj . '.resumes', ['title' => $ar_lessonname, 'ar_materialname' => $ar_materialname, 'ar_levelname' => $ar_levelname, 'rounds1' => $rounds1, 'rounds2' => $rounds2, 'asccat' => $all->get(), 'allcat' => $all->orderBy('id', 'desc')->get(), 'fullcat' => $fullcat, 'idlevel' => $idlevel, 'idspeciality' => $idspeciality, 'idmaterial' => $idmaterial, 'idlesson' => $idlesson, 'level' => $level, 'newsallarticles' => $newsallarticles, 'bacallarticles' => $bacallarticles, 'alllessons' => $alllessons, 'ar_lessonname' => $ar_lessonname, 'lesson' => $lesson, 'material' => $material, 'ar_specialityname' => $ar_specialityname, 'speciality' => $speciality]);
 }
开发者ID:ewaschool,项目名称:dirassa,代码行数:36,代码来源:Resume.php

示例15: 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


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