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


PHP Post::all方法代码示例

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


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

示例1: submit_link

 public function submit_link()
 {
     // for submitting the link created to the database
     $submit_link = Post::submit_link();
     $posts = Post::all();
     require_once 'views/posts/index.php';
 }
开发者ID:nikitrivedi,项目名称:php_mvc,代码行数:7,代码来源:posts_controller.php

示例2: adminDashboard

 public function adminDashboard()
 {
     $moderate_count = User::where('role_id', 1)->get()->count();
     $post_count = Post::all()->count();
     $posts = Post::orderBy('id', 'desc')->distinct()->where('is_approved', 1)->take(5)->get();
     return View::make('admin.adminDashboard')->withPage('dashboard')->with('moderate_count', $moderate_count)->with('post_count', $post_count)->withPosts($posts);
 }
开发者ID:niranjanbala,项目名称:SH_Dashboard_Code,代码行数:7,代码来源:AdminController.php

示例3: testAll

 public function testAll()
 {
     $post = Post::all();
     $debug = last(DB::getQueryLog());
     $this->assertCount(3, $post);
     $this->assertEquals('select * from "posts" where "published" = ? and "status" = ?', $debug['query']);
 }
开发者ID:pixelpeter,项目名称:eloquent-filterable,代码行数:7,代码来源:EloquentFilterTest.php

示例4: dashboard

 /**
  * Show Admin Dashboard
  * GET /admin/dashboard
  *
  * @return Response
  */
 public function dashboard()
 {
     $users = \DB::table('users')->count();
     $posts = \Post::all()->count();
     $feedback = \Feedback::all()->count();
     return \View::make('admin.dashboard', compact('posts', 'users', 'feedback'));
 }
开发者ID:pogliozzy,项目名称:larabase,代码行数:13,代码来源:AdminController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::all();
     $data = compact('posts');
     // equal to ->with('posts', $posts);
     return View::make('home.index')->with('posts', $posts);
 }
开发者ID:ahoyhoy-sw,项目名称:laravel_workshop_2014,代码行数:12,代码来源:PostsController.php

示例6: testPaginate

 public function testPaginate()
 {
     $posts = Paginator::paginatePosts(Post::all(), 0, 5);
     $res = $this->e->paginate($posts, 'year');
     $keys = array_keys($res);
     $this->assertTrue(2010 < $keys[0] and $keys[0] < 2020);
     $this->assertTrue(isset($res[$keys[0]]['posts']));
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:8,代码来源:TwigExtensionTest.php

示例7: run

 public function run()
 {
     $faker = Faker::create();
     Comment::truncate();
     $posts = Post::all();
     foreach (range(1, 50) as $index) {
         Comment::create(['user_id' => $faker->numberBetween($min = 1, $max = 10), 'post_id' => rand(1, $posts->count()), 'text' => $faker->paragraph($nbSentences = 3), 'attachment_id' => 0]);
     }
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:9,代码来源:CommentsTableSeeder.php

示例8: index

 /**
  * Display a listing of the resource.
  * @param live
  * @return Response
  */
 public function index($live = null)
 {
     if (isset($live)) {
         $posts = Post::where('live', $live)->get();
     } else {
         $posts = Post::all();
     }
     return $posts;
 }
开发者ID:MahmoodKhalid,项目名称:laravelandangular,代码行数:14,代码来源:PostController.php

示例9: isUniqueSlug

 public function isUniqueSlug($slug)
 {
     $posts = Post::all();
     foreach ($posts as $post) {
         if ($post->slug == $slug) {
             return false;
         }
     }
     return true;
 }
开发者ID:anthony87burns,项目名称:blog.dev,代码行数:10,代码来源:Post.php

示例10: addLang

 public static function addLang($lang_id)
 {
     $pages = Post::all();
     foreach ($pages as $item) {
         $page_lang = new PostLang();
         $page_lang->lang_id = $lang_id;
         $page_lang->post_id = $item->id;
         $page_lang->save();
     }
 }
开发者ID:vcorobceanu,项目名称:WebAPL,代码行数:10,代码来源:Post.php

示例11: run

 public function run()
 {
     $faker = Faker::create();
     //add these posts
     for ($i = 0; $i < 10; $i++) {
         $comment = new Comment();
         $comment->post_id = Post::all()->random(1)->id;
         $comment->user_id = User::all()->random(1)->id;
         $comment->comment = $faker->text($maxNbChars = 200);
         $comment->save();
     }
 }
开发者ID:asteph,项目名称:Laravel_Blog,代码行数:12,代码来源:CommentsTableSeeder.php

示例12: index

 public function index()
 {
     // Check if user has sent a search query
     if ($query = Input::get('query', false)) {
         // Use the Elasticquent search method to search ElasticSearch
         //        $posts = Post::search($query);
         $posts = Post::searchByQuery(["bool" => ['must' => ['multi_match' => ['query' => Input::get('query', ''), 'fields' => ["title^2", "content"]]], "should" => ['match' => ['tags' => ["query" => Input::get('query', ''), "type" => "phrase"]]]]]);
     } else {
         // Show all posts if no query is set
         $posts = Post::all();
     }
     return View::make('home', compact('posts'));
 }
开发者ID:eavillacis,项目名称:example_elasticsearch,代码行数:13,代码来源: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: run

 public function run()
 {
     /*delete all existing images*/
     DB::table('images')->delete();
     $faker = Faker::create();
     for ($i = 0; $i < 10; $i++) {
         $image = new Image();
         $image->post_id = Post::all()->random()->id;
         $image->url = $faker->imageUrl(640, 480, 'city');
         $image->image_title = '';
         $image->save();
     }
 }
开发者ID:JBSanAntonio,项目名称:LaravelBlog,代码行数:13,代码来源:ImagesTableSeeder.php

示例15: tags

 public function tags($slug)
 {
     if (!$slug) {
         redirect('web');
     }
     // $join = 'LEFT JOIN post_to_tags a ON(posts.id = a.post_id) WHERE tag_id = '.$id.' AND post_status = "active"' ;
     $join = " LEFT JOIN post_to_tags a " . "ON(posts.id = a.post_id) " . "WHERE a.tag_id = " . Tag::first(array('slug' => $slug))->id . " " . "AND post_type = 'post' ORDER BY id DESC";
     $data['posts'] = Post::all(array('joins' => $join));
     $data['navs'] = Post::all(array('post_type' => 'page'));
     if (!$data['posts']) {
         redirect('web/error/404/NotFound');
     }
     $this->theme->view('tags', $data);
 }
开发者ID:ferdinal,项目名称:GulingCMS,代码行数:14,代码来源:web.php


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