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


PHP Categories::where方法代码示例

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


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

示例1: post

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function post(Request $request, $post)
 {
     $qGetTags = Tags::all();
     $qGetCategories = Categories::where('cID', '!=', 1)->get();
     $qArticle = $post;
     return view('user.show-post', compact('qGetTags', 'qGetCategories', 'qArticle'));
 }
开发者ID:NguyenHoangThien,项目名称:learningBlog,代码行数:12,代码来源:home.php

示例2: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::create();
     $categories = Categories::where('parent_id', '>=', 0)->get();
     $baseUrl = 'http://7xkn9n.com1.z0.glb.clouddn.com/img/';
     $string = file_get_contents(__DIR__ . "/../data/products.json");
     $products = json_decode($string, true);
     $cate_ids = [];
     foreach ($categories as $category) {
         $cate_ids[] = $category->id;
     }
     foreach ($products as $productData) {
         try {
             $name = $productData['meta']['title'];
             $content = '';
             if (isset($productData['content'])) {
                 $content = str_replace('<h2 class="title">百科词条</h2>', '', $productData['content']);
             }
             $klass = $productData['meta']['class']['text'];
             $category = Categories::where('name', $klass)->get();
             $description = substr($content, 0, 100);
             $cid = $faker->randomElement($cate_ids);
             if ($category->count() == 1) {
                 $cid = $category[0]->id;
             }
             $pieces = preg_split("/\\//i", $productData['meta']['image']);
             $product = Product::create(['name' => $name, 'slug' => $name, 'description' => $description, 'keywords' => $klass, 'cover' => $baseUrl . $pieces[count($pieces) - 1], 'category_id' => $cid, 'user_id' => 1]);
             $detailTopic = Topic::create(['title' => $name, 'slug' => $name, 'product_id' => $product->id, 'user_id' => 1, 'keywords' => $name, 'description' => $description, 'content' => $content, 'is_product_detail_topic' => true]);
             $product->detail_topic_id = $detailTopic->id;
             $product->save();
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:40,代码来源:ProductsTableSeeder.php

示例3: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     if ($request->cID) {
         $category = Categories::where("cID", $request->cID)->first();
     } else {
         $category = new Categories();
     }
     $category->cName = $request->cName;
     $category->cDescription = $request->cDes;
     $category->cParentID = $request->categoryParent;
     $category->cIsActive = is_null($request->active) ? 0 : 1;
     $file = Input::file('image');
     if (!is_null($file)) {
         $destinationPath = public_path() . '/assets/images/';
         $fileName = explode(".", $file->getClientOriginalName())[0];
         $fileName = $fileName . rand(1, 9999) . "." . $file->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $fileName);
         $category->cIcon = $fileName;
         if ($request->cID) {
             //remove file name before
         }
     }
     $category->save();
     return Redirect::action('admin\\category@index');
     /* https://laracasts.com/discuss/channels/general-discussion/laravel-5-image-upload-and-resize?page=1
      *  Link upload and resize image
      */
 }
开发者ID:NguyenHoangThien,项目名称:learningBlog,代码行数:34,代码来源:category.php

示例4: getForm

 public function getForm($id = null)
 {
     $dataAdmin = new PrProviders();
     $modelProviders = new PrTypes();
     $modelCategories = new Categories();
     $listProviders = $modelProviders->where('flagactive', PrTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listProviders = [null => 'Select un tipo'] + $listProviders;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     if (!is_null($id)) {
         $dataAdmin = PrProviders::find($id);
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataAdmin', 'listProviders'), ['listCategories' => $listCategories, 'listCategories' => $listCategories]);
 }
开发者ID:josmel,项目名称:buen,代码行数:14,代码来源:ProviderWaitingController.php

示例5: getForm

 public function getForm($id = null, $modulo = null)
 {
     $modelCategories = new Categories();
     $listTypes = PuTypes::whereFlagactive(PuTypes::STATE_ACTIVE)->lists('name_type', 'id')->toArray();
     $listTypes = [null => 'Select un tipo'] + $listTypes;
     $listCategories = $modelCategories->where('flagactive', Categories::STATE_ACTIVE)->lists('name_category', 'id')->toArray();
     $listCategories = [null => 'Select una categoria'] + $listCategories;
     $dataPost = PuAds::find($id);
     if (!is_null($id)) {
         $dataPost = PuAds::find($id);
         $dataPicture = PuPicture::wherePuAdId($id)->first();
         $dataPost->picture = !empty($dataPicture->url) ? "{$dataPost->picture}" : null;
         $dataPost->pr_provider_id = !empty($dataPost->pr_provider_id) ? "{$dataPost->pr_provider_id}" : 0;
     }
     return viewc('admin.' . self::NAMEC . '.form', compact('dataPost', 'modulo'), ['listCategories' => $listCategories, 'listTypes' => $listTypes]);
 }
开发者ID:josmel,项目名称:buen,代码行数:16,代码来源:PublicationController.php

示例6: crawler

 public function crawler(Request $request)
 {
     $this->allLinks = array();
     if ($request->server('REQUEST_METHOD') == "POST") {
         $domain = strpos($request->domainURL, "http://") !== false ? $request->domainURL : "http://" . $request->domainURL;
         $this->domain = $domain;
         $this->count = $request->limitPages;
         $this->index_current = 0;
         $this->limit_page = $request->limitPages;
         $this->allLinks[0] = array("page" => $domain, "status" => "", "mark" => "");
         $this->find_character = $request->checkCharacter;
         $this->spider($domain);
     }
     $allLinks = $this->allLinks;
     $qGetTags = Tags::all();
     $qGetCategories = Categories::where('cID', '!=', 1)->get();
     return view('functionally.crawler', compact('qGetTags', 'qGetCategories', 'allLinks'));
 }
开发者ID:NguyenHoangThien,项目名称:learningBlog,代码行数:18,代码来源:functionally.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validation = Validator::make(Input::all(), $this->CreateRules);
     if ($validation->fails()) {
         if ($categoryFind = Categories::where('name', '=', Input::get('name'))->count()) {
             return Redirect::back()->withErrors($validation)->withInput();
         }
         return Redirect::back()->withErrors($validation)->withInput();
     }
     if ($validation->passes()) {
         $category = new Categories();
         $category->name = Input::get('name');
         if ($category->save()) {
             return Redirect::intended('admin/categories')->with('message', sprintf(trans('message.msg_category_create_success'), $category->name));
         }
         return Redirect::intended('admin/categories')->withErrors(array('errors' => sprintf(trans('message.msg_category_update_fail'), Input::get('name'))));
     }
     return Redirect::back()->with('warning', trans('message.msg_category_input_error'))->withErrors($validation)->withInput();
 }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例8: allcategories

 public function allcategories()
 {
     $dataCategory = Categories::where('flagactive', '!=', 0)->select('pu_categories.*', DB::raw('CONCAT("' . asset('') . '", picture) AS picture'))->get();
     return $dataCategory;
 }
开发者ID:josmel,项目名称:buen,代码行数:5,代码来源:Categories.php

示例9: categories

 public function categories()
 {
     $categories = Categories::where('parent_id', -1)->get();
     return view('categories')->with('categories', $categories)->with('active_menu', 'categories');
 }
开发者ID:jiketao,项目名称:jiketao-laravel,代码行数:5,代码来源:PagesController.php


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