當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。