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


PHP Article::where方法代码示例

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


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

示例1: forUser

 /**
  * Get all of the articles for a given user.
  **
  *
  * @return mixed
  */
 public function forUser()
 {
     if ($this->user->is_admin) {
         return $this->article->all()->sortBy('created_at');
     }
     return $this->article->where('user_id', $this->user->id)->orderBy('created_at', 'asc')->get();
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:13,代码来源:ArticleRepository.php

示例2: getIndex

 /**
  * Return all all articles
  */
 public function getIndex(Request $request)
 {
     $articles = Article::where('active', 1);
     /**
      * Filter by category
      */
     if ($request->has('category')) {
         $filter_category = $request->get('category');
         $category = Category::find($filter_category);
         // if there is no category with this name
         if (!$category) {
             return response()->json(['code' => '404', 'message' => 'There is no category with this id'], 404);
         }
         // if category is exists
         $articles = $category->articles();
     }
     /**
      * Filter by order
      */
     if ($request->has('order')) {
         $fitler_order = $request->get('order');
         if ($fitler_order == 'desc' || $fitler_order == 'asc') {
             $articles->orderBy('views', $fitler_order);
         }
     }
     return response()->json(['code' => '200', 'data' => $articles->get()], 200);
 }
开发者ID:arabyalhomsi,项目名称:arabyalhomsi-blog,代码行数:30,代码来源:ArticleController.php

示例3: show

 public function show($slug)
 {
     // $article = Article::with('authors', 'tags', 'pictures', 'videos', 'category')->findOrFail($id);
     $article = Article::where(['articles.slug' => $slug])->with('authors', 'tags', 'pictures', 'videos', 'category')->first();
     $pictures = $article->picturesArray;
     return view('article.show', compact('article', 'pictures'));
 }
开发者ID:OlegGetm,项目名称:abs_lara,代码行数:7,代码来源:ArticleController.php

示例4: show

 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($slug)
 {
     $article = Article::where('slug', $slug)->firstOrFail();
     $articleSide = DB::select("select title, slug, image_lead\n                                   from articles\n                                   WHERE ID !='{$article->id}' limit 5;");
     $googlePhrahes = Google::limit(30)->orderBy('id', 'DESC')->get();
     return view('article', compact('article', 'articleSide', 'googlePhrahes'));
 }
开发者ID:pavelzin,项目名称:co-w-ciazy,代码行数:13,代码来源:ArticleController.php

示例5: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     \Route::bind('articleslug', function ($value) {
         return \App\Article::where('slug', $value)->with('user')->with('writer')->with('screenshot.image')->firstOrFail();
     });
 }
开发者ID:becast,项目名称:GameReviewSite,代码行数:13,代码来源:RouteServiceProvider.php

示例6: showArticle

 public function showArticle($id)
 {
     $article = Article::findOrFail($id);
     $news = Article::where('id', '>', $article->id)->orderBy('id', 'DESC')->take(NEW_OLD_ARTICLE);
     $olds = Article::where('id', '<', $article->id)->orderBy('id', 'DESC')->take(NEW_OLD_ARTICLE);
     return view('frontend.articles.main')->with(compact('news', 'article', 'olds'));
 }
开发者ID:louisthaihv,项目名称:colong,代码行数:7,代码来源:IndexController.php

示例7: index

 public function index(Article $article)
 {
     //        $articles = $article->getArticles();
     $articles = Article::where('active', '=', 1)->where('published_at', '<=', Carbon::now())->latest('published_at')->simplePaginate(4);
     $articles->setPath('articles');
     return view('articles.articles')->with('articles', $articles);
 }
开发者ID:sashacitylight,项目名称:sashasite,代码行数:7,代码来源:ArticlesController.php

示例8: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('article', function ($slug) {
         return Article::where('slug', $slug)->firstOrFail();
     });
     parent::boot($router);
 }
开发者ID:Ravend6,项目名称:laravel_base_v5.2,代码行数:13,代码来源:RouteServiceProvider.php

示例9: index

 public function index()
 {
     $choosenLang = \Session::get('locale');
     $tags = Tag::where('lang', '=', $choosenLang)->get();
     $articles = Article::where('lang', '=', $choosenLang)->paginate(2);
     return view('index', compact('articles', 'tags'));
 }
开发者ID:ramigit3D,项目名称:article,代码行数:7,代码来源:HomeController.php

示例10: getArticle

 public function getArticle($cate, $arti)
 {
     $arti = substr($arti, 0, -5);
     //cắt chuối ".html" cuối article alias
     $category = Category::where("category_alias", $cate)->first();
     //lấy category đầu tiên có alias bằng tham số category alias
     $listCategory = Category::all(["id", "category_alias", "category_name"])->toArray();
     $allArticles = Article::all(["id", "title", "alias", "summary", "content", "image", "category_id", "author", "created_date"])->where('category_id', $category["id"])->toArray();
     //lấy tất cả bài viết trong category
     if ($category != null) {
         $message = "";
         $category_name = $category["category_name"];
         if (count($allArticles) == 0) {
             $message = 'Không có bài viết nào.';
         } else {
             $article = Article::where("alias", $arti)->first();
             if ($article != null) {
                 $relateArticles = Article::where('category_id', $category["id"])->where("id", '!=', $article["id"])->orderBy('created_date', 'desc')->get()->take(2)->toArray();
                 return view('front.blog.article', compact('listCategory', 'relateArticles', 'message', 'category_name', 'article', 'mess'));
             } else {
                 $message = "Không tìm thấy bài viết phù hợp";
                 return view('front.blog.error', compact('listCategory', 'message', 'category_name'));
             }
         }
         return view('blog.index', compact('listCategory', 'message', 'category_name'));
     }
 }
开发者ID:quangtruong16994,项目名称:laravel,代码行数:27,代码来源:BlogController.php

示例11: detail

 public function detail($slug, Request $request)
 {
     $slug = Input::get('slug');
     $articleModel = new Article();
     $article = $articleModel->where('slug', $slug)->firstOrFail();
     return $article;
 }
开发者ID:strever,项目名称:blog,代码行数:7,代码来源:Blog.php

示例12: article

 public function article($categorykey, $articlekey)
 {
     $article = Article::where('key', $articlekey)->first();
     if ($article != null) {
         // metadata
         $site_title = $article->name . ' - ' . Config::findByKey('site_title')->first()->value;
         SEOMeta::setTitle($site_title);
         SEOMeta::setDescription($article->meta_description);
         SEOMeta::addKeyword([$article->meta_keywords]);
         SEOMeta::addMeta('article:published_time', $article->created_at->toW3CString(), 'property');
         if (isset($article->categories->first()->name)) {
             SEOMeta::addMeta('article:section', $article->categories->first()->name, 'property');
         }
         OpenGraph::setTitle($site_title);
         OpenGraph::setDescription($article->meta_description);
         OpenGraph::setUrl(route('article', ['categorykey' => $categorykey, 'articlekey' => $articlekey]));
         OpenGraph::addProperty('type', 'article');
         OpenGraph::addProperty('locale', app()->getLocale());
         OpenGraph::addProperty('locale:alternate', ['vi-vn', 'en-us']);
         OpenGraph::addImage($article->getFirstAttachment());
         OpenGraph::addImage($article->attachments->lists('path'));
         OpenGraph::addImage(['url' => Image::url($article->getFirstAttachment(), 300, 300, array('crop')), 'size' => 300]);
         // end metadata
         return view('frontend.sites.article', compact('article'));
     } else {
         return view('errors.404');
     }
 }
开发者ID:phantsang,项目名称:M62mPuixxb9vGyP0BuLp274k,代码行数:28,代码来源:SiteControllers.php

示例13: Home

 public function Home()
 {
     $flash = Event::where('start_date', '<=', new \Datetime())->where('end_date', '>=', new \Datetime())->orderBy('id', 'desc')->take(1)->get()->first();
     $articles = Article::where('id', '!=', isset($flash) ? $flash->article->id : 0)->orderBy('publish_at', 'desc')->orderBy('id', 'desc')->take(5)->get();
     $ffttNews = FFTTNew::orderBy('date', 'desc')->take(3)->get();
     return view('front.home', array('articles' => $articles, 'NewsFlash' => $flash, 'ffttNews' => $ffttNews));
 }
开发者ID:kbiyo,项目名称:ARTTv2,代码行数:7,代码来源:HomeController.php

示例14: boot

 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('article', function ($id) {
         return \App\Article::where('slug', $id)->first();
     });
     parent::boot($router);
 }
开发者ID:belhard-user,项目名称:group2,代码行数:12,代码来源:ModelProviders.php

示例15: index

 public function index($username)
 {
     $articles = Article::where('user_id', '=', auth()->user()->id)->orderBy('created_at', 'desc')->get();
     $categories = Category::all();
     $tags = Tag::all();
     return view('articles.new')->with(['articles' => $articles, 'categories' => $categories, 'tags' => $tags]);
 }
开发者ID:otsaan,项目名称:e-blog,代码行数:7,代码来源:ArticleController.php


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