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


PHP Categories::find方法代码示例

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


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

示例1: actionShow

 /**
  * Показывает контент
  * @return string
  * @TODO Нужно предусмотреть возможность вывода разного контента, привязаного к одной категории
  *
  */
 public function actionShow()
 {
     $this->cat_id = Yii::$app->getRequest()->getQueryParam('id') ? Yii::$app->getRequest()->getQueryParam('id') : null;
     $cat_obg = Categories::find()->where('id = ' . $this->cat_id)->one();
     $allContent = Articles::find()->where('cat_id = ' . $this->cat_id)->all();
     $allArticlesForPager = Articles::find()->where(['cat_id' => $this->cat_id]);
     $countQueryCont = clone $allArticlesForPager;
     $pagesGlobal = new Pagination(['totalCount' => $countQueryCont->count(), 'pageSize' => 1, 'forcePageParam' => false, 'pageSizeParam' => false]);
     $artPages = $allArticlesForPager->offset($pagesGlobal->offset)->limit($pagesGlobal->limit)->all();
     foreach ($allContent as $article) {
         //var_dump($this->cat_id);
         $this->article_id = $article->id;
         $article = Articles::findOne($this->article_id);
         $allArticles = ArticlesContent::find()->where(['articles_id' => $this->article_id])->orderBy(['id' => SORT_DESC]);
         //var_dump($allArticles); exit;
         $countQuery = clone $allArticles;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => isset($article->onepages) ? $article->onepages : 0, 'forcePageParam' => false, 'pageSizeParam' => false]);
         $models = $allArticles->offset($pages->offset)->limit($pages->limit)->all();
         $this->source = Source::find()->where(['id' => $models[0]->source_id])->one()->title;
         $this->author = Author::find()->where(['id' => Source::find()->where(['id' => $models[0]->source_id])->one()->author_id])->one()->name;
         $this->articles[] = ['article' => $article, 'contents' => $models, 'pages' => $pages, 'source' => $this->source, 'author' => $this->author];
     }
     //var_dump($this->articles); exit;
     return $this->renderPartial($cat_obg->action, ['articles' => $this->articles, 'cat' => $this->cat_id, 'pagesGlobal' => $pagesGlobal, 'artPages' => $artPages, 'cat_obg' => $cat_obg]);
 }
开发者ID:roman1970,项目名称:lis,代码行数:31,代码来源:DefaultController.php

示例2: postForm

 public function postForm(FormCategoryRequest $request)
 {
     if (!empty($request)) {
         $pathImage = $request->get('picture', null);
         $data = $request->all();
         if ($request->hasfile('picture')) {
             $validator = Validator::make($request->all(), ['picture' => ['mimes:jpg,png,jpeg']]);
             if ($validator->fails()) {
                 return redirect(action('Admin\\CategoryController@postForm'))->withErrors($validator)->withInput();
             }
             $file = $request->file('picture');
             $nameimage = date('Ymdhis') . rand(1, 1000) . '.' . $file->getClientOriginalExtension();
             $file->move(public_path() . "/dinamic/category/", $nameimage);
             $pathImage = '/dinamic/category/' . $nameimage;
             $data['picture'] = $pathImage;
         }
         $data['flagactive'] = $request->get('flagactive', 1);
         if ($request->id) {
             $obj = Categories::find($request->id);
             $obj->update($data);
             $idTips = $obj->id;
         } else {
             $obj = Categories::create($data);
             $idTips = $obj->id;
         }
         return redirect('admpanel/' . self::NAMEC)->with('messageSuccess', 'Caracteristicas Guardado');
     }
     return redirect('admpanel')->with('messageError', 'Error al guardar el tip');
 }
开发者ID:josmel,项目名称:buen,代码行数:29,代码来源:CategoryController.php

示例3: actionIndex

 /**
  * Lists all Categories models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $dataProvider = new ActiveDataProvider(['query' => Categories::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
开发者ID:apfrankowski,项目名称:insights,代码行数:12,代码来源:CategoriesController.php

示例4: actionList

 public function actionList($id = 0)
 {
     if ($id != 0) {
         return $this->redirect(['album/list', 'id' => $id]);
     }
     $q = Categories::find()->where(['handler' => $this->id]);
     $dataProvider = new ActiveDataProvider(['query' => $q]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }
开发者ID:kintastish,项目名称:mobil_old,代码行数:9,代码来源:GalleryController.php

示例5: actionKlavarosCats

 public function actionKlavarosCats()
 {
     $res = [];
     $m = Categories::find()->where(['site_id' => 13])->all();
     foreach ($m as $h) {
         $res[] = $h->name;
     }
     return json_encode($res);
 }
开发者ID:roman1970,项目名称:lis,代码行数:9,代码来源:TestController.php

示例6: actionDelete

 /**
  * Удаляет категорию
  * @param $id
  * @return \yii\web\Response
  * @throws \yii\web\HttpException
  */
 public function actionDelete($id)
 {
     if ($model = $this->loadModel($id)->delete()) {
         $cats = Categories::find()->all();
         return $this->render(['index', ['cats' => $cats]]);
     } else {
         throw new \yii\web\HttpException(404, 'Cant delete record.');
     }
 }
开发者ID:roman1970,项目名称:lis,代码行数:15,代码来源:CategoriesController.php

示例7: actionUpdate

 /**
  * Updates an existing Categories model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $categoryId
  * @return mixed
  */
 public function actionUpdate($categoryId)
 {
     $categories = Categories::find()->all();
     //findAllExceptOne($categoryId);
     $model = $this->findModel($categoryId);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'categoryId' => $model->category_id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
开发者ID:asopin,项目名称:shop,代码行数:17,代码来源:CategoriesController.php

示例8: actionUpdate

 /**
  * Updates an existing Product model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $itemId
  * @return mixed
  */
 public function actionUpdate($itemId)
 {
     $categories = Categories::find()->all();
     // need this for dropDownList in views/product/_form.php
     $model = $this->findModel($itemId);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'itemId' => $model->item_id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
开发者ID:asopin,项目名称:shop,代码行数:17,代码来源:ProductController.php

示例9: actionList

 public function actionList($categoryId = null)
 {
     /** @var Category $category */
     $category = null;
     $categories = Categories::find()->indexBy('category_id')->orderBy('category_id')->all();
     $productsQuery = Product::find();
     if ($categoryId !== null && isset($categories[$categoryId])) {
         $category = $categories[$categoryId];
         $productsQuery->where(['category_id' => $this->getCategoryIds($categories, $categoryId)]);
     }
     $productsDataProvider = new ActiveDataProvider(['query' => $productsQuery, 'pagination' => ['pageSize' => 10]]);
     return $this->render('list', ['category' => $category, 'menuItems' => $this->getMenuItems($categories, isset($category->category_id) ? $category->category_id : null), 'productsDataProvider' => $productsDataProvider]);
 }
开发者ID:asopin,项目名称:shop,代码行数:13,代码来源:CatalogController.php

示例10: remove

 public function remove($category_id)
 {
     $category = Categories::find($category_id);
     $category->delete();
     if (Input::get('with_posts', '0') == '1') {
         Posts::where('category_id', $category_id)->delete();
         Notifications::add('Category removed with posts', 'success');
     } else {
         Posts::where('category_id', $category_id)->update(['category_id' => '1']);
         Notifications::add('Category removed. Posts moved to Uncategorized', 'success');
     }
     return Redirect::route('root-categories');
 }
开发者ID:vitos8686,项目名称:0ez,代码行数:13,代码来源:CategoriesController.php

示例11: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['category_id' => $this->category_id, 'parent_category_id' => $this->parent_category_id, 'date_added' => $this->date_added, 'date_modified' => $this->date_modified, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'category_name', $this->category_name]);
     return $dataProvider;
 }
开发者ID:asopin,项目名称:shop,代码行数:21,代码来源:CategoriesSearch.php

示例12: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_by' => $this->created_by, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
开发者ID:openi-ict,项目名称:api-builder,代码行数:21,代码来源:CategoriesSearch.php

示例13: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('idArea');
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'service_level_agreement_asignment' => $this->service_level_agreement_asignment, 'service_level_agreement_completion' => $this->service_level_agreement_completion]);
     $query->andFilterWhere(['like', 'categories.name', $this->name])->andFilterWhere(['like', 'categories.description', $this->description])->andFilterWhere(['like', 'areas.name', $this->id_area]);
     return $dataProvider;
 }
开发者ID:Hyuchiha,项目名称:SAU,代码行数:22,代码来源:CategoriesSearch.php

示例14: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'tree' => $this->tree]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
开发者ID:juratitov,项目名称:justcoded,代码行数:23,代码来源:CategoriesSearch.php

示例15: actionIndex

 /**
  * @return string
  */
 public function actionIndex()
 {
     $uploadFile = new UploadForm();
     //var_dump($_POST);
     if (Yii::$app->request->isPost) {
         $uploadFile->file = UploadedFile::getInstance($uploadFile, 'file');
         // var_dump($uploadFile->file); exit;
         if ($uploadFile->file && $uploadFile->validate()) {
             $uploadFile->file->saveAs('uploads/' . Yii::$app->translater->translit($uploadFile->file->baseName) . '.' . $uploadFile->file->extension);
         } else {
             print_r($uploadFile->getErrors());
             exit;
         }
     }
     $cats = Categories::find()->where('site_id =' . $this->site->id)->roots()->all();
     $articles = Articles::find()->where('site_id =' . $this->site->id . ' or site_id = 13')->all();
     //$cats = Categories::find()->leaves()->all();
     return $this->render('index', ['cats' => $cats, 'articles' => $articles, 'uploadFile' => $uploadFile]);
 }
开发者ID:roman1970,项目名称:lis,代码行数:22,代码来源:DefaultController.php


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