• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP models\Category类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: actionDrop

 public function actionDrop()
 {
     $model = new SurveyResult();
     $catList = ArrayHelper::map(Category::find()->asArray()->all(), 'id', 'name');
     $subcatList = ArrayHelper::map(Subcategory::find()->asArray()->all(), 'id', 'name');
     return $this->render('drop', ['model' => $model, 'catList' => $catList, 'subcatList' => $subcatList]);
 }
开发者ID:aiskimzhi,项目名称:rep,代码行数:7,代码来源:SiteController.php


示例17: actionIndex

 /**
  * Lists all Service models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new ServiceSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $cat = Category::find()->orderBy('name_pt')->asArray()->all();
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cat' => $cat]);
 }
开发者ID:hlcborg,项目名称:primlacosadv,代码行数:11,代码来源:ServiceController.php


示例18: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $videos = glob(public_path() . '/b/*');
     usort($videos, function ($a, $b) {
         $a = (int) basename($a, '.webm');
         $b = (int) basename($b, '.webm');
         if ($a == $b) {
             return 0;
         }
         return $a < $b ? -1 : 1;
     });
     $category = \App\Models\Category::where('shortname', '=', 'misc')->first();
     $user = \App\Models\User::find(1);
     foreach ($videos as $video) {
         if (\App\Models\Video::whereFile(basename($video))->count() > 0) {
             continue;
         }
         $v = new \App\Models\Video();
         $v->user()->associate($user);
         $v->category()->associate($category);
         $v->hash = sha1_file($video);
         $v->file = basename($video);
         $v->save();
     }
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:30,代码来源:VideoTableSeeder.php


示例19: testUpdate

 /**
  * @depends testStore
  */
 public function testUpdate($category)
 {
     $this->put(route('api.admin.category.item', $category), json_encode(['category_name' => 'test edited']));
     $category = Category::find($category->id);
     $this->assertEquals('test edited', $category->category_name);
     $this->assertResponseOk();
 }
开发者ID:kshar1989,项目名称:dianpou,代码行数:10,代码来源:CategoryTest.php


示例20: updateVisibility

 /**
  * Update the visibility of a category
  *
  * @param $id
  * @param $visible
  * @return mixed
  */
 public function updateVisibility($id, $visible)
 {
     $category = Category::find($id);
     $category->visible = $visible;
     $category->save();
     return $category;
 }
开发者ID:FomKiosk,项目名称:API-Laravel,代码行数:14,代码来源:CategoryRepository.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP models\City类代码示例发布时间:2022-05-23
下一篇:
PHP models\Categories类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap