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


PHP Article::find方法代码示例

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


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

示例1: actionView

 /**
  * Displays a single Article model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $this->layout = 'main2';
     $model = $this->findModel($id);
     $articles = Article::find()->where(['status' => 'ACTIVE', 'type' => 'NEWS', 'category' => $model->category])->limit(4)->all();
     return $this->render('view', ['model' => $model, 'articles' => $articles]);
 }
开发者ID:frankpaul142,项目名称:chaide,代码行数:12,代码来源:ArticleController.php

示例2: actionIndex

 public function actionIndex()
 {
     $query = Article::find();
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $query->count()]);
     $articles = $query->orderBy('id')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['articles' => $articles, 'pagination' => $pagination]);
 }
开发者ID:proufa,项目名称:basic,代码行数:7,代码来源:ArticleController.php

示例3: edit

 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id = null)
 {
     //返回/resource/view/nweaver/commuity下的create.blade.php页面
     //编辑文章文章
     $article = Article::find($id);
     return view('nweaver.commuity.edit', compact('article'));
 }
开发者ID:saviorZSC,项目名称:zsc_laravel,代码行数:13,代码来源:CommuityController.php

示例4: actionCreate

 /**
  * Creates a new Visa model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($num = 1)
 {
     $this->layout = "main";
     $model = new Visa();
     $article = Article::find()->where(['type' => 103])->one();
     $visaDetails = [];
     $numApply = isset($_POST['Visa']['numapply']) ? $_POST['Visa']['numapply'] : $num;
     for ($i = 0; $i < $numApply; $i++) {
         $visaDetails[] = new Visadetail();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $visaId = $model->id;
         if (isset($_POST['Visadetail'])) {
             foreach ($_POST['Visadetail'] as $index => $arr) {
                 foreach ($arr as $i => $val) {
                     $visaDetails[$index - 1][$i] = $val;
                 }
                 $visaDetails[$index - 1]['id_visa'] = $visaId;
             }
             foreach ($visaDetails as $visaDetail) {
                 if ($visaDetail->save()) {
                 }
             }
             Yii::$app->mailer->compose('@app/views/mail/mail-layout', ['model' => $model, 'visaDetails' => $visaDetails])->setFrom($model->email)->setTo('duytu2005@gmail.com')->setSubject('Book tour')->send();
             return $this->render('success', ['model' => $model, 'visaDetails' => $visaDetails, 'article' => $article]);
         }
     } else {
         if (Yii::$app->request->isAjax) {
             return $this->renderAjax('create', ['model' => $model, 'article' => $article, 'visaDetails' => $visaDetails]);
         } else {
             return $this->render('create', ['model' => $model, 'visaDetails' => $visaDetails, 'article' => $article]);
         }
     }
 }
开发者ID:nguyendtu,项目名称:VietvietTravel,代码行数:39,代码来源:VisaController.php

示例5: destroy

 public function destroy($id)
 {
     $article = Article::find($id);
     $article->delete();
     Notification::success('The article was deleted.');
     return Redirect::route('admin.articles.index');
 }
开发者ID:daniellimafreire,项目名称:l4-site-tutorial,代码行数:7,代码来源:ArticlesController.php

示例6: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $data['article'] = Article::find($id);
     ArticleStatus::update_view_number($id);
     $this->setCommonData();
     return view('website.article', $data);
 }
开发者ID:xinzou,项目名称:blog,代码行数:13,代码来源:ArticleController.php

示例7: findArticle

 /**
  * @param $slug
  * @return Article
  */
 protected function findArticle($slug)
 {
     if (($model = Article::find()->where(['slug' => $slug])->one()) !== null) {
         return $model;
     } else {
         return false;
     }
 }
开发者ID:amarchenkov,项目名称:myCMS,代码行数:12,代码来源:ArticleUrlRule.php

示例8: actionView

 public function actionView($id)
 {
     $model = Article::find()->published()->with('author')->andWhere(['id' => $id])->one();
     if (!$model) {
         throw new NotFoundHttpException();
     }
     return $this->render('view', ['model' => $model]);
 }
开发者ID:samatic,项目名称:yii2-starter,代码行数:8,代码来源:ArticleController.php

示例9: actionArticle

 public function actionArticle($year, $month, $day, $id)
 {
     $item = Article::find(['id_string' => $id, 'date' => $year . $month . $day]);
     if (is_null($item)) {
         throw new Exception('Нет такой статьи');
     }
     $item->incViewCounter();
     return $this->render(['item' => $item]);
 }
开发者ID:dram1008,项目名称:gleb,代码行数:9,代码来源:SiteController.php

示例10: delete

 public function delete(Article $article, $id)
 {
     $data = $article->find($id);
     if (!$data) {
         return response()->json(['error' => 'data not found'], 404);
     }
     $data->delete();
     return response()->json(200);
 }
开发者ID:aririfani,项目名称:laravel-rest-api,代码行数:9,代码来源:ArticleController.php

示例11: actionViewall

 public function actionViewall($cid = 2)
 {
     $query = Article::find()->where(['cid' => $cid, 'published' => 1]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count()]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->orderBy('ordering')->all();
     $cat = \app\models\Categories::findOne($cid);
     return $this->render('viewall', ['model' => $models, 'cat' => $cat, 'pages' => $pages]);
 }
开发者ID:jatuponp,项目名称:discovery,代码行数:9,代码来源:SiteController.php

示例12: search

 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Article::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'slug' => $this->slug, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'body', $this->body]);
     return $dataProvider;
 }
开发者ID:samatic,项目名称:yii2-starter,代码行数:15,代码来源:ArticleSearch.php

示例13: delete

 public function delete($id)
 {
     $id = intval($id);
     $articleInstance = Article::find($id);
     if (!$articleInstance->trashed()) {
         $articleInstance->delete();
         return Redirect::back()->withResult('operation complete');
     } else {
         return Redirect::back()->withResult('this article has been deleted already.');
     }
 }
开发者ID:Albertao,项目名称:myblog,代码行数:11,代码来源:ArticleAdminController.php

示例14: postSimpan

 public function postSimpan($value = '')
 {
     $model = new Article();
     if (Input::get('id') > 0) {
         $model = Article::find(Input::get('id'));
     }
     $model->title = Input::get('title');
     $model->description = Input::get('description');
     $model->save();
     return Redirect::to('article');
 }
开发者ID:alfhan,项目名称:dishubparpostel,代码行数:11,代码来源:ArticleController.php

示例15: actionSubscribe

 /**
  * AJAX
  * Добавляет site_update
  * Делает рассылку
  *
  * @param integer $id - идентификатор новости
  *
  * @return string
  */
 public function actionSubscribe($id)
 {
     $item = Article::find($id);
     if (is_null($item)) {
         return self::jsonError(101, 'Не найдена статья');
     }
     Subscribe::add($item);
     SiteUpdate::add($item);
     $item->update(['is_added_site_update' => 1]);
     return self::jsonSuccess();
 }
开发者ID:Makeyko,项目名称:galaxysss,代码行数:20,代码来源:Admin_articleController.php


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