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


PHP Post::orderBy方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::orderBy('date_start', 'DESC')->get();
     $postPublish = Post::countAllPostsPublished()->get();
     $postUnpublish = Post::countAllPostsUnpublished()->get();
     return view('post.index', compact('posts', 'postPublish', 'postUnpublish'));
 }
开发者ID:AndryRana,项目名称:ConfPHP,代码行数:12,代码来源:PostController.php

示例2: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $hashtag = $this->argument('hashtag');
     $GetterClass = '\\App\\Getters\\' . $this->argument('provider') . 'Getter';
     $TransformerClass = 'App\\Transformers\\' . $this->argument('provider') . 'Transformer';
     $getter = new $GetterClass();
     $this->info('Getting posts from ' . $this->argument('provider'));
     $posts = $getter->getList($this->argument('howmany'), $this->argument('hashtag'));
     // transform posts
     foreach ($posts as $key => $post) {
         $transformer = new $TransformerClass($post);
         $currentPost = $transformer->get();
         // store if it doesn't already exist
         if (!Post::has($currentPost['post_id'])) {
             // check if post is popular enough
             if ($this->argument('qualityThreshold')) {
                 if ($transformer->isPopular($this->argument('qualityThreshold'))) {
                     Post::create($currentPost);
                 }
             } else {
                 Post::create($currentPost);
             }
         }
     }
     // Cache last 50 posts
     $this->comment('Caching last fifty posts');
     $lastFiftyPosts = \App\Post::orderBy('date_published', 'DESC')->take(50)->get();
     Cache::put('lastFiftyPosts', $lastFiftyPosts, 5);
 }
开发者ID:aboustayyef,项目名称:ysn,代码行数:34,代码来源:getLatestPosts.php

示例3: getIndex

 public function getIndex()
 {
     $posts = Post::orderBy('created_at', 'desc')->take(5)->get();
     $products = Product::orderBy('created_at', 'desc')->take(5)->get();
     $references = Reference::orderBy('created_at', 'desc')->take(5)->get();
     return view('admin/index', ['posts' => $posts, 'products' => $products, 'references' => $references]);
 }
开发者ID:smax22,项目名称:personal-homepage,代码行数:7,代码来源:AdminController.php

示例4: index

 public function index()
 {
     $posts = Post::orderBy('page_view', 'DESC')->get();
     $pageType = 'Random';
     $data = compact('posts', 'pageType');
     return view('posts.index', $data);
 }
开发者ID:Reg-Li,项目名称:crud-lab-assets,代码行数:7,代码来源:HotController.php

示例5: index

 public function index()
 {
     $postType = '文章總覽';
     $posts = \App\Post::orderBy('created_at', 'desc')->paginate(5);
     $data = compact('postType', 'posts');
     return view('posts.index', $data);
 }
开发者ID:hsaung,项目名称:formrequest,代码行数:7,代码来源:PostsController.php

示例6: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $posts = Post::orderBy('created_at', 'desc')->paginate(6, ['*'], 'p');
     $comments = Comment::all();
     $data = ['comments' => $comments, 'posts' => $posts];
     return view('posts.index', $data);
 }
开发者ID:GA010081,项目名称:crud,代码行数:12,代码来源:PostsController.php

示例7: feed

 public function feed()
 {
     $feed = Feed::make();
     // cache the feed for 60 minutes (second parameter is optional)
     $feed->setCache(60, 'laravelFeedKey');
     // check if there is cached feed and build new only if is not
     if (!$feed->isCached()) {
         // creating rss feed with our most recent 20 posts
         $posts = Post::orderBy('created_at')->take(20)->get();
         // set your feed's title, description, link, pubdate and language
         //FIXME: These are duplicated
         $feed->title = config('seotools.meta.defaults.title');
         $feed->description = config('seotools.meta.defaults.description');
         $feed->logo = 'http://yoursite.tld/logo.jpg';
         $feed->link = route('feed');
         $feed->setDateFormat('datetime');
         // 'datetime', 'timestamp' or 'carbon'
         $feed->pubdate = $posts[0]->created_at;
         $feed->lang = 'en';
         $feed->setShortening(true);
         // true or false
         $feed->setTextLimit(200);
         // maximum length of description text
         foreach ($posts as $post) {
             // set item's title, author, url, pubdate, description and content
             $image = null;
             if ($post->coverImage) {
                 $image = ['url' => url($post->coverImage), 'type' => 'image/jpeg'];
             }
             $feed->add($post->title, 'Jesse Collis', $post->url(), $post->created_at, $post->subtitle, $post->body, $image);
         }
     }
     return $feed->render('atom');
 }
开发者ID:melbournecocoa,项目名称:website,代码行数:34,代码来源:PostsController.php

示例8: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // $posts = Post::all();
     // $data = ['posts' => $posts,];
     // 自動分頁
     $posts = Post::orderBy('created_at', 'desc')->paginate(5);
     $data = compact('posts');
     return view('posts.index', $data);
 }
开发者ID:40143146,项目名称:crud-lab-assets,代码行数:14,代码来源:PostsController.php

示例9: index

 public function index()
 {
     /* return view('admin.post.index')
        ->withPosts(Post::all());*/
     $posts = Post::orderBy('published_at', 'desc')->paginate(config('blog.posts_per_page'));
     //分页配置
     return view('admin.post.index', compact('posts'));
     //分页
 }
开发者ID:boosb,项目名称:test,代码行数:9,代码来源:PostController.php

示例10: index

 public function index()
 {
     if (Input::has('group_id')) {
         $posts = Post::where('group_id', Input::get('group_id'))->paginate(10)->toArray();
     } else {
         $posts = Post::orderBy('id', 'desc')->paginate(10)->toArray();
     }
     return view('admin.posts.index', compact('posts'));
 }
开发者ID:rhofma,项目名称:rhofma.de,代码行数:9,代码来源:AdminPostController.php

示例11: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     if (Auth::check()) {
         $skip = Input::get('p') * 10;
         $posts = Post::orderBy('points', 'desc')->take(10)->skip($skip)->get();
         return view('newsfeed', ['posts' => $posts]);
     } else {
         return view('splash', ['submitted' => FALSE]);
     }
 }
开发者ID:smckeehan,项目名称:confr,代码行数:15,代码来源:HomepageController.php

示例12: updateSideBarCache

 public static function updateSideBarCache()
 {
     $categories = Category::all();
     $posts = Post::orderBy('updated_at', 'desc')->limit(2)->get();
     if (Cache::has('categories') || Cache::has('posts')) {
         Cache::flush();
     }
     Cache::forever('posts', compact('posts'));
     Cache::forever('categories', compact('categories'));
 }
开发者ID:shempignon,项目名称:laravel-5-blog-mvc,代码行数:10,代码来源:PostServiceProvider.php

示例13: index

 public function index()
 {
     if (Auth::user()->admin) {
         $posts = Post::orderBy('created_at', 'desc')->get();
         return view('admin.index', ['posts' => $posts]);
     } else {
         $posts = Post::where('autor_id', Auth::user()->id)->orderBy('created_at', 'desc')->get();
         return view('autor.index', ['posts' => $posts]);
     }
 }
开发者ID:edilsonribeiro,项目名称:etec.palmital.quati,代码行数:10,代码来源:PostController.php

示例14: index

 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $search = $request->get("search");
     if (!empty($search)) {
         $posts = Post::where('name', 'Like', '%' . $search . '%')->orderBy('created_at', 'DESC')->paginate(3);
     } else {
         $posts = Post::orderBy('created_at', 'DESC')->paginate(3);
     }
     return view("posts.index", compact("posts"));
 }
开发者ID:essteffan,项目名称:laravel,代码行数:16,代码来源:PostController.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index($category_id = null)
 {
     // if a category was passed, use that
     // if no category, get all posts
     // if ($category_id) {
     //     $posts = Post::where('category_id', $category_id);
     // }
     // else {
     $posts = Post::orderBy('created_at', 'DESC')->paginate(15);
     // }
     return view('posts.index', ['posts' => $posts]);
 }
开发者ID:NCKU-Official,项目名称:ncku-report-server,代码行数:17,代码来源:PostController.php


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