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


PHP Article::whereIn方法代码示例

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


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

示例1: show

 public function show($tag)
 {
     $rs = Tag::where('tag', $tag)->get();
     $arr = array();
     foreach ($rs as $v) {
         array_push($arr, $v->article_id);
     }
     $articles = Article::whereIn('id', $arr)->get();
     $tags = Tag::select('tag')->distinct()->get();
     return view('member.tags.show', compact('tag', 'tags', 'articles'));
 }
开发者ID:Panfen,项目名称:mango,代码行数:11,代码来源:TagsController.php

示例2: getArticles

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function getArticles($id, $number)
 {
     $category = Category::whereName($id)->first();
     $sources = $category->sources;
     $ids = [];
     foreach ($sources as $source) {
         $ids[] = $source->id;
     }
     $articles = Article::whereIn('source_id', $ids)->orderBy('date', 'DESC')->paginate($number);
     return ['name' => $category->name, 'id' => $category->id, 'image_url' => $category->image_url, 'articles' => $articles->toArray()];
 }
开发者ID:NewsRepost,项目名称:Fetcher,代码行数:17,代码来源:CategoryController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $usr = Practicante::where('email', '=', $request->user()->email)->get();
     $actual_rank = Tag::where('name', Config::get('constants.ranks')[$usr[0]->actual_rank])->get()[0]->id;
     $withTags = DB::table('article_tag')->where('tag_id', $actual_rank)->get(array('article_id'));
     //Cleaning the array
     $justTags = array();
     foreach ($withTags as $key => $value) {
         array_push($justTags, $value->article_id);
     }
     $articles = Article::whereIn('id', $justTags)->get();
     return View('practicante.tecnicas.index')->with('articles', $articles)->with('actual_rank', $usr[0]->actual_rank)->with('ranks', Config::get('constants.ranks'));
 }
开发者ID:gratereaux,项目名称:practicing-laravel,代码行数:18,代码来源:TecnicasController.php

示例4: articlesTag

 public function articlesTag($tag)
 {
     $withTags = DB::table('article_tag')->where('tag_id', $tag)->get(array('article_id'));
     //Cleaning the array
     $justTags = array();
     foreach ($withTags as $key => $value) {
         array_push($justTags, $value->article_id);
     }
     $articles = Article::whereIn('id', $justTags)->get();
     if (count($articles) == 0) {
         return response()->json(['error' => ['message' => 'No existen articulos con esta etiqueta']], 404);
     }
     return response()->json($articles, 200);
 }
开发者ID:gratereaux,项目名称:practicing-laravel,代码行数:14,代码来源:ApiController.php

示例5: checkout

 public function checkout(Request $request)
 {
     if (isset($_COOKIE['basket'])) {
         $entries = $_COOKIE['basket'];
         $entries = json_decode($entries);
     } else {
         return redirect('/');
     }
     $ids = array_pluck($entries, 'article_id');
     $items = Article::whereIn('id', $ids)->get();
     //->toArray();
     $items = $items->keyBy('id');
     $order = Order::create(['name' => $request->name, 'address' => $request->address, 'phone' => $request->phone]);
     $summary = [];
     $total_cost = 0;
     foreach ($entries as $entry) {
         OrdersToArticles::create(['article_id' => $entry->article_id, 'order_id' => $order->id, 'price' => $items->get($entry->article_id)->price, 'quantity' => $entry->amount]);
         $summary[] = ['article_id' => $entry->article_id, 'title' => $items->get($entry->article_id)->title, 'price' => $items->get($entry->article_id)->price, 'amount' => $entry->amount];
         $total_cost += end($summary)['price'] * end($summary)['amount'];
     }
     setcookie('basket', '', 0, '/');
     //удаляем куки
     return view('finish_order', ['order' => $order, 'entries' => $summary, 'total' => $total_cost]);
 }
开发者ID:pavelhodak,项目名称:myblog,代码行数:24,代码来源:BasketController.php

示例6: deleteArticle

 public function deleteArticle()
 {
     $articles = Input::get('formarr', array());
     Articlecontent::whereIn('article_id', $articles)->delete();
     foreach ($articles as $article) {
         Article::find($article)->menu_relations()->detach();
     }
     Article::whereIn('id', $articles)->delete();
     return 1;
 }
开发者ID:nitin-prodigi,项目名称:mesa,代码行数:10,代码来源:ArticleController.php

示例7: getFavoritesByModel

 /**
  * Return the favorites of a certain model or table, leave the data as is under $model->settings['favorites']
  *
  * @param $model
  * @param $data
  *
  * @return object|false
  */
 static function getFavoritesByModel($model, $data)
 {
     if (!isset($data[$model])) {
         return false;
     }
     $data = array_keys($data[$model]);
     switch ($model) {
         case 'articles':
             return Article::whereIn('id', $data)->get();
         case 'sites':
             return Site::whereIn('id', $data)->get();
         case 'professions':
             return Profession::whereIn('id', $data)->get();
         case 'classifieds':
             return Classified::whereIn('id', $data)->get();
         case 'albums':
             return Album::whereIn('id', $data)->get();
         case 'agoda':
             return AgodaHotel::whereIn('hotel_id', $data)->get();
         default:
             return false;
     }
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:31,代码来源:MyHelper.php

示例8: postBatch

 /**
  * batch update
  * @param string $act
  * @return json
  */
 public function postBatch($act = 'update')
 {
     $result = false;
     $ids = \Request::input('ids');
     $idsArr = explode(',', $ids);
     switch ($act) {
         case 'delete':
             $result = Article::whereIn('id', $idsArr)->delete();
             break;
         case 'update':
             $key = \Request::input('key');
             $value = \Request::input('value');
             $tempData = $this->parseKey($key, $value);
             $result = Article::whereIn('id', $idsArr)->update($tempData);
             break;
     }
     $msg = [];
     if ($result) {
         $msg['status'] = 'success';
     } else {
         $msg['status'] = 'failed';
     }
     return response(json_encode($msg))->header('Content-Type', 'application/json');
 }
开发者ID:jay4497,项目名称:j4cms,代码行数:29,代码来源:ArticleController.php


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