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


PHP Post::orderBy方法代码示例

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


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

示例1: getIndex

 /**
  * Returns all the blog posts.
  *
  * @return View
  */
 public function getIndex()
 {
     // Get all the blog posts
     $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10);
     // Show the page
     return View::make('site/blog/index', compact('posts'));
 }
开发者ID:hilmysyarif,项目名称:l4-bootstrap-admin,代码行数:12,代码来源:BlogController.php

示例2: getIndex

 /**
  * Returns all the blog posts.
  *
  * @return View
  */
 public function getIndex()
 {
     // $home = $this->post->where('slug', '=', 'home')->first();
     // if(count($home) == 1){
     // 	return Theme::make('site/blog/home', compact('home'));
     // } else {
     $posts = $this->post->orderBy('created_at', 'DESC')->paginate(10);
     return Theme::make('site/blog/index', compact('posts'));
     // }
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:15,代码来源:BlogController.php

示例3: getIndex

 public function getIndex()
 {
     $posts = Post::orderBy('id', 'desc')->paginate(10);
     $posts->getEnvironment()->setViewName('pagination::simple');
     $this->layout->title = 'Home Page | Laravel 4 Blog';
     $this->layout->main = View::make('home')->nest('content', 'index', compact('posts'));
 }
开发者ID:singh7889,项目名称:Laravel-blog-post,代码行数:7,代码来源:BlogController.php

示例4: getIndex

 /**
  * Show a list of all the blog posts.
  *
  * @return View
  */
 public function getIndex()
 {
     // Grab all the blog posts
     $posts = Post::orderBy('created_at', 'DESC')->paginate(10);
     // Show the page
     return View::make('admin/blogs/index', compact('posts'));
 }
开发者ID:nozkok,项目名称:laravel-4-starter,代码行数:12,代码来源:AdminBlogsController.php

示例5: index

 /**
  * Display a listing of latest questions.
  *
  * @return Response
  */
 public function index()
 {
     $sort = array('name' => '', 'direction' => '');
     switch (Input::get('sort')) {
         case 'newest':
             $sort['name'] = 'created_at';
             $sort['direction'] = 'desc';
             break;
         case 'oldest':
             $sort['name'] = 'created_at';
             $sort['direction'] = 'asc';
         case 'most viewed':
             $sort['name'] = 'view_count';
             $sort['direction'] = 'desc';
             break;
         default:
             $sort['name'] = 'created_at';
             $sort['direction'] = 'desc';
             break;
     }
     $questions = Post::orderBy($sort['name'], $sort['direction'])->where('post_type_id', '=', '1')->paginate(10);
     $tags = Tag::all();
     $data = array('questions' => $questions, 'tags' => $tags);
     // return var_dump($posts);
     return View::make('public.questions.index', $data);
 }
开发者ID:UnderDogg,项目名称:StackOverflow-Clone,代码行数:31,代码来源:QuestionsController.php

示例6: adminIndexAll

 public function adminIndexAll()
 {
     $posts = Post::orderBy('updated_at', 'desc')->paginate();
     return View::make('admin.dicts.list', ['columns' => ['ID', 'Пользователь', 'Текст', 'Рубрика', 'Лайки', 'Комментарии', 'Время', '', ''], 'data' => $posts->transform(function ($post) {
         return ['id' => $post->id, 'user' => link_to("admin/users{$post->user_id}", $post->user->name), 'text' => link_to("admin/posts/{$post->id}/edit", $post->text), 'category' => link_to("/admin/categories/{$post->category_id}/edit", $post->category->title), 'likes' => link_to("admin/posts/{$post->id}/likes", $post->likes->count()), 'comments' => link_to("admin/posts/{$post->id}/comments", $post->comments->count()), 'time' => Carbon::createFromTimestamp($post->created_at), 'edit' => link_to("/admin/posts/{$post->id}/edit", 'редактировать'), 'delete' => link_to("/admin/posts/{$post->id}/delete", 'удалить')];
     }), 'actions' => [['link' => 'admin/posts/delete', 'text' => 'Удалить выбранное']], 'links' => $posts->links(), 'title' => 'Посты']);
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:7,代码来源:PostsController.php

示例7: run

 public function run()
 {
     $faker = Faker\Factory::create();
     DB::table('favorites')->truncate();
     foreach (range(1, 30) as $index) {
         $post = Post::orderBy(DB::raw('RAND()'))->first();
         User::orderBy(DB::raw('RAND()'))->first()->favorites()->attach($post->id);
     }
 }
开发者ID:billwaddyjr,项目名称:Favorite-This-Demo,代码行数:9,代码来源:FavoritesTableSeeder.php

示例8: search

 public function search()
 {
     //TODO Rate limit
     $query = Input::get('query');
     $max = Input::has('size') && Input::get('size') < 61 ? Input::get('size') : 25;
     $last = Input::has('last') ? Input::get('last') : Post::orderBy('id', 'desc')->first()->id;
     $posts = Post::where('text', 'ilike', '%' . $query . '%')->where('id', '<', $last)->orderBy('id', 'desc')->with('user', 'likes', 'comments', 'images', 'geos', 'cars', 'cars.images', 'category')->take($max)->get();
     return $this->respond($this->collectionTransformer->transformPosts($posts));
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:9,代码来源:SearchController.php

示例9: it_orders_the_values

 /** @test **/
 public function it_orders_the_values()
 {
     $this->createPostsTable();
     $this->insertOn('posts', ['title' => 'House', 'content' => 'Repeating']);
     $this->insertOn('posts', ['title' => 'Sherlock', 'content' => 'Elementary Watson.']);
     $this->insertOn('posts', ['title' => 'Psych!', 'content' => 'Repeating']);
     $posts = Post::orderBy('title', 'DESC')->get();
     $this->assertEquals('Sherlock', $posts->first()->title);
     $this->assertEquals('House', $posts->last()->title);
 }
开发者ID:alchemyphp,项目名称:cms,代码行数:11,代码来源:DatabaseModelTest.php

示例10: APIGetImages

 public function APIGetImages()
 {
     $posts = Post::orderBy('id', 'DESC')->where('group_id', $this->id)->get();
     $returnStr = array();
     foreach ($posts as $post) {
         if ($post->statustype == 'image') {
             $returnStr[] = $post->displayAPIMontage();
         }
     }
     return $returnStr;
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:11,代码来源:Group.php

示例11: index

 /**
  * Display a listing of videos
  *
  * @return Response
  */
 public function index()
 {
     $search_value = Input::get('s');
     if (!empty($search_value)) {
         $posts = Post::where('title', 'LIKE', '%' . $search_value . '%')->orderBy('created_at', 'desc')->paginate(10);
     } else {
         $posts = Post::orderBy('created_at', 'DESC')->paginate(10);
     }
     $user = Auth::user();
     $data = array('posts' => $posts, 'user' => $user, 'admin_user' => Auth::user());
     return View::make('admin.posts.index', $data);
 }
开发者ID:rinodung,项目名称:hello-video-laravel,代码行数:17,代码来源:AdminPostController.php

示例12: rankings

 public function rankings()
 {
     //Top 10 usuarios
     $top10user = UserProfile::orderBy('points', 'desc')->take(10)->get();
     //Top 10 mejores publicaciones - Todo el tiempo
     $top10post = Post::orderBy('point', 'desc')->take(10)->get();
     //Top 10 mejores publicaciones - Mes
     $top10month = Post::where('created_at', '>=', new DateTime('-1 months'))->orderBy('point', 'desc')->take(10)->get();
     //Top 10 mejores publicaciones - Mes
     $top10week = Post::where('created_at', '>=', new DateTime('-1 weeks'))->orderBy('point', 'desc')->take(10)->get();
     return View::make('ranking', ['top10user' => $top10user, 'top10post' => $top10post, 'top10month' => $top10month, 'top10week' => $top10week]);
 }
开发者ID:Thormod,项目名称:JusThinkGreen,代码行数:12,代码来源:HomeController.php

示例13: blog

 public function blog()
 {
     $this->load->model('post');
     $this->load->library('pagination');
     $posts = Post::all();
     $config['base_url'] = base_url() . 'blog/page/';
     $config['total_rows'] = $posts->count();
     $config['per_page'] = 5;
     $skip = ($this->uri->segment(3) - 1) * $config['per_page'];
     $this->pagination->initialize($config);
     $data = ['menu' => 'blog', 'posts' => Post::orderBy('created_at', 'desc')->skip($skip)->take($config['per_page'])->get(), 'links' => $this->pagination->create_links()];
     $this->load->view('front/blog', $data);
 }
开发者ID:harithaakella,项目名称:CS597-Project-Code,代码行数:13,代码来源:Welcome.php

示例14: trending

 public function trending()
 {
     $data['page'] = 'trending';
     $data['pagetype'] = 'trending';
     $data['images'] = Post::select('posts.*', DB::raw('count(votes.id) as total'))->leftJoin('votes', 'posts.id', '=', 'votes.post_id')->groupBy('posts.id')->orderBy('total', 'desc');
     if (Auth::user()) {
         $data['images'] = $data['images']->with(array('votes' => function ($query) {
             $query->where('user_id', Auth::id());
         }))->take(12)->get();
     } else {
         $data['images'] = $data['images']->take(12)->get();
     }
     $data['others'] = Post::orderBy(DB::raw('RAND()'))->take(10)->get();
     return View::make('scrollpost')->with($data);
 }
开发者ID:ChavezRuston,项目名称:fansemo,代码行数:15,代码来源:HomeController.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     /*$posts = Post::all();
     		
      		$this->layout->title = 'Liste des articles';
     		$this->layout->main = View::make('dash')->nest('content','posts.index',compact('posts'));*/
     $sortby = Input::get('sortby');
     $order = Input::get('order');
     if ($sortby && $order) {
         $posts = Post::orderBy($sortby, $order)->paginate(10);
     } else {
         $posts = Post::orderBy('created_at', 'DESC')->paginate(10);
     }
     $this->layout->title = 'Liste des articles';
     $this->layout->main = View::make('dash')->nest('content', 'posts.index', compact('posts', 'sortby', 'order'));
 }
开发者ID:jeremy6680,项目名称:easy-peasy-cms,代码行数:21,代码来源:PostController.php


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