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


PHP models\Category类代码示例

本文整理汇总了PHP中app\models\Category的典型用法代码示例。如果您正苦于以下问题:PHP Category类的具体用法?PHP Category怎么用?PHP Category使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCategoryRequest $request)
 {
     $category = new Category();
     $data = $request->input();
     $category->create($data);
     return Redirect()->route('categories');
 }
开发者ID:RsanabriaZ,项目名称:web-catalog,代码行数:13,代码来源:CategoryController.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $pro = new Product();
     $adSlotObj = new Adslot();
     $catObj = new Category();
     $brandObj = new Brand();
     /*getting all products for all slots(currently we have 7 slots)*/
     $adSlot_data = $adSlotObj->with(['products'])->get();
     /*t1-t7*/
     // dd($adSlot_data[4]['products'][0]);
     $category_temp_data = $catObj->orderBy('created_at')->take(10)->get();
     /*f1-f10*/
     $brand_data = $brandObj->with(['products'])->get();
     $category_data = [];
     foreach ($category_temp_data as $cat_id) {
         $cat_latest_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('photo_1');
         $cat_latest_product_id = $pro->where('category_id', '=', $cat_id['id'])->orderBy('created_at')->take(1)->pluck('id');
         $cat_random_product = $pro->where('category_id', '=', $cat_id['id'])->orderBy(DB::raw('RAND()'))->take(6)->get();
         $cat_brands = $pro->with(['brand'])->where('category_id', '=', $cat_id['id'])->take(5)->get();
         $cat_products_random_photos = [];
         foreach ($cat_random_product as $photo) {
             $cat_products_random_photos[] = $photo;
         }
         $category_data[] = ['color' => $cat_id['color'], 'floor' => $cat_id['floor'], 'name' => $cat_id['name'], 'desc' => $cat_id['description'], 'logo' => $cat_id['logo'], 'latest_photo_id' => $cat_latest_product_id, 'latest_photo' => $cat_latest_product, 'random_photos' => $cat_products_random_photos, 'brands' => $cat_brands];
     }
     return view('landing_page', compact(['adSlot_data', 'category_data']));
 }
开发者ID:khakanali,项目名称:OpenMAll,代码行数:32,代码来源:Landing.php

示例3: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /*Default Category*/
     $category = new Category();
     $category->user_id = 0;
     $category->name = "Food & Drink";
     $category->save();
     $category = new Category();
     $category->user_id = 0;
     $category->name = "Bills";
     $category->save();
     $category = new Category();
     $category->user_id = 0;
     $category->name = "Transportation";
     $category->save();
     $category = new Category();
     $category->user_id = 0;
     $category->name = "Cellular";
     $category->save();
     $category = new Category();
     $category->user_id = 0;
     $category->name = "Tax";
     $category->save();
     $admin = new Admin();
     $admin->username = "admin";
     $admin->password = "123456";
     $admin->secret = "123456";
     $admin->save();
 }
开发者ID:Thitiwut,项目名称:money-flow,代码行数:34,代码来源:simpleData.php

示例4: deleteCategory

 /**
  * Delete a category.
  *
  * @param Category $category
  * @return mixed
  */
 public function deleteCategory(Category $category)
 {
     $result = \DB::transaction(function () use($category) {
         return $category->delete();
     });
     return $result;
 }
开发者ID:bohap,项目名称:online-study,代码行数:13,代码来源:CategoryRepository.php

示例5: addCategory

 public static function addCategory($title, $mid)
 {
     $category = new Category();
     $category->title = $title;
     $category->mid = $mid;
     $category->sort_id = 1;
     $category->save();
 }
开发者ID:bajian,项目名称:BiliPusher,代码行数:8,代码来源:DataAccess.php

示例6: index

 public function index(Advertisement $advertModel)
 {
     $b1_baner = Baner::where('type', 'b1')->get();
     $b2_baner = Baner::where('type', 'b2')->get();
     $latest_advert = $advertModel->get_last_advert();
     $popular_advert = $advertModel->get_popular_advert();
     $categoryModel = new Category();
     $categories = $categoryModel->get_order_count();
     return view('site.front')->with('b1_baner', $b1_baner)->with('b2_baner', $b2_baner)->with('latest_advert', $latest_advert)->with('popular_advert', $popular_advert)->with('categories', $categories);
 }
开发者ID:andriy-sa,项目名称:laravel,代码行数:10,代码来源:DefaultController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Category::truncate();
     $categoryNames = ['coding', 'social', 'faith', 'health', 'minimalism'];
     foreach ($categoryNames as $name) {
         $category = new Category(['name' => $name]);
         $category->user()->associate(User::first());
         $category->save();
     }
 }
开发者ID:JennySwift,项目名称:lists,代码行数:15,代码来源:CategorySeeder.php

示例8: actionArticle

 /**
  * 具体文章显示
  * @return string
  */
 public function actionArticle()
 {
     $categoryName = Yii::$app->request->get('dir');
     $articleName = Yii::$app->request->get('name');
     $categoryModel = new Category();
     $articleInfo = $categoryModel->getArticleBody($categoryName, $articleName);
     $parser = new GithubMarkdown();
     $articleInfo['content'] = $parser->parse($articleInfo['content']);
     $articleInfo['category'] = $categoryName;
     return $this->render('article', ['article' => $articleInfo]);
 }
开发者ID:waltye,项目名称:blog,代码行数:15,代码来源:SiteController.php

示例9: get_add_test

 public function get_add_test(Category $category)
 {
     if (!$this->bool_has_role) {
         return $this->roleHelper->call_redirect();
     } else {
         $arr_categories_raw = $category->all()->toArray();
         $arr_categories_processed = $category->process_categories($arr_categories_raw);
         $data = array('arr_logged_in_user' => $this->arr_logged_in_user, 'arr_categories_processed' => $arr_categories_processed);
         return view('tests/add_test')->with('data', $data);
     }
 }
开发者ID:jenniferbradley49,项目名称:testing_app_two,代码行数:11,代码来源:TestController.php

示例10: destroy

 /**
  *
  * @param Category $category
  * @return Response
  */
 public function destroy(Category $category)
 {
     try {
         $category->delete();
         return response([], Response::HTTP_NO_CONTENT);
     } catch (\Exception $e) {
         //Integrity constraint violation
         if ($e->getCode() === '23000') {
             $message = 'Category could not be deleted. It is in use.';
         } else {
             $message = 'There was an error';
         }
         return response(['error' => $message, 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST);
     }
 }
开发者ID:JennySwift,项目名称:lists,代码行数:20,代码来源:CategoriesController.php

示例11: confirmUnpublished

 public function confirmUnpublished(Product $product)
 {
     $authors_list = $product->is->authors->lists('lastname');
     $category = Category::where('id', $product->organizations->first()->pivot->cat_id)->first(['name']);
     $editor = $product->is->editor->e_name;
     return view('admin.products.unpublished.confirm', compact('product', 'authors_list', 'category', 'editor'));
 }
开发者ID:nicsmyrn,项目名称:library,代码行数:7,代码来源:UnpublishedController.php

示例12: actionTopic

 public function actionTopic()
 {
     static $topics = ['today', 'hot'];
     $topic = \Yii::$app->request->get('topic');
     $p = \Yii::$app->request->get('p', 1);
     if (in_array($topic, $topics)) {
         switch ($topic) {
             case 'hot':
                 $title = '热门推荐';
                 $list = Blog::hotList();
                 break;
             default:
                 break;
         }
     } else {
         if (is_numeric($topic)) {
             $cid = intval($topic);
             $list = Blog::getListByCid($cid);
             $title = Category::getName($cid);
         }
     }
     $this->getView()->params['title'] = $title;
     $this->getView()->params['description'] = $title;
     return $this->render('/site/list', ['data' => $list]);
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:25,代码来源:BlogController.php

示例13: actionDelete

 public function actionDelete($id)
 {
     $model = Category::find()->where(['id' => $id])->one();
     $model->unlinkAll('posts', true);
     Category::deleteAll(['id' => $id]);
     return $this->actionNew();
 }
开发者ID:stanislavdev1993,项目名称:blog,代码行数:7,代码来源:CategoryController.php

示例14: add

 public static function add(BlogForm $blogform)
 {
     $blog = new Blog();
     $blog->uid = \Yii::$app->user->getId();
     $blog->title = htmlspecialchars($blogform->title);
     $blog->content = htmlspecialchars($blogform->content);
     $blog->tags = $blogform->tags;
     $blog->cid = $blogform->cid ? $blogform->cid : 0;
     $blog->status = $blogform->status ? $blogform->status : self::STATUS_PUBLISH;
     $blog->is_private = $blogform->is_private ? $blogform->is_private : 0;
     $blog->allow_review = $blogform->allow_review ? $blogform->allow_review : 1;
     $blog->addtime = $blog->uptime = time();
     $analyse = self::analyse($blogform->content);
     if (!$blogform->description) {
         $blog->description = $analyse['description'];
     } else {
         $blog->description = $blogform->description;
     }
     //$blog->image = $blogform->image ? $blogform->image : $analyse['image'];
     $blog->image = $analyse['image'];
     $blog->thumb = $analyse['thumb'];
     $result = $blog->insert();
     if ($result) {
         Tags::add($blog->tags, $blog->id);
         if ($blog->status == self::STATUS_PUBLISH) {
             Category::countInc($blog->cid);
         }
         return true;
     } else {
         return false;
     }
 }
开发者ID:Crocodile26,项目名称:php-1,代码行数:32,代码来源:Blog.php

示例15: update

 /**
  * Update the specified resource in storage.
  *
  * @param  Requests\Backend\StoreCategoryRequest $request
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\Backend\StoreCategoryRequest $request, $id)
 {
     $category = Category::findOrFail($id);
     $this->authorize($category);
     $category->update($request->all());
     return redirect()->action('Backend\\CategoryController@show', [$category]);
 }
开发者ID:niefufeng,项目名称:drip,代码行数:14,代码来源:CategoryController.php


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