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


PHP Post::all方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->postParser = new PostParser();
     $this->tags = Tag::all();
     $this->dificultyLevels = PostDificulty::all();
     $this->posts = Post::all();
 }
开发者ID:joaumg-deprecated,项目名称:joaumg_com,代码行数:7,代码来源:PostTableSeeder.php

示例2: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // dd('index');
     $posts = Post::all();
     $data = ['posts' => $posts, 'pageType' => 'All Post'];
     return view('posts.index', $data);
 }
开发者ID:Reg-Li,项目名称:crud-lab-assets,代码行数:12,代码来源:PostsController.php

示例3: like

 public function like(Request $request)
 {
     onlyAllowPostRequest($request);
     $post_id = $request->input('id');
     $user_id = $request->input('user');
     /**
      * Dữ liệu trả về
      */
     $response = new stdClass();
     $likes = Like::all()->where('user_id', intval($user_id))->where('post_id', intval($post_id));
     if ($likes->count() > 0) {
         $response->error = true;
         $response->error_msg = 'Bạn đã cảm ơn bài viết này!';
         return response()->json($response);
     }
     $like = Like::create(['user_id' => $user_id, 'post_id' => $post_id]);
     $posts = Post::all()->where('id', intval($post_id));
     if ($posts->count() == 0) {
         $response->error = true;
         $response->error_msg = 'Bạn đã cảm ơn bài viết này!';
         return response()->json($response);
     }
     $count_like = intval($posts->first()->like);
     $count_like++;
     $p = DB::table('posts')->where('id', intval($post_id))->update(['like' => $count_like]);
     $response->error = false;
     $response->msg = 'Cảm ơn bạn!';
     return response()->json($response);
 }
开发者ID:uethackathon02,项目名称:uethackathon2015_team2server,代码行数:29,代码来源:LikeConfirmedController.php

示例4: index

 public function index()
 {
     if (\Request::ajax()) {
         return Post::all();
     }
     return view('post.index');
 }
开发者ID:Yuth-Set,项目名称:cms,代码行数:7,代码来源:PostController.php

示例5: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $category = Category::all();
     $post = Post::all();
     $data = array('post' => $post, 'category' => $category);
     return view('blog.index', $data);
 }
开发者ID:elukuro,项目名称:project01,代码行数:12,代码来源:BlogController.php

示例6: posts

 public static function posts($type = null, $data = null)
 {
     if ($type and $data) {
         return Post::where($type, $data)->get();
     }
     return Post::all();
 }
开发者ID:ConsoleTVs,项目名称:Laralum,代码行数:7,代码来源:Laralum.php

示例7: index

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

示例8: handle

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $posts = Post::all(['slug', 'updated_at']);
     $works = Work::all(['slug', 'updated_at']);
     $this->sitemap = new Sitemap(public_path('sitemap.xml'));
     $this->comment('Starting generating the Sitemap...');
     // Home
     $this->addItem(config('app.url') . '/', 0.9);
     // Resume
     $this->addItem(config('app.url') . '/resume', 0.8);
     // Blog index
     $this->addItem(config('app.url') . '/blog', 0.8);
     // Works index
     $this->addItem(config('app.url') . '/works', 0.8);
     // @codeCoverageIgnoreStart
     // Blog posts
     foreach ($posts as $post) {
         $this->addItem(config('app.url') . '/blog/' . $post->slug, 0.7);
     }
     // Works items
     foreach ($works as $work) {
         $this->addItem(config('app.url') . '/works/' . $work->slug, 0.7);
     }
     // @codeCoverageIgnoreEnd
     $this->sitemap->write();
     $this->comment('Sitemap generated successfully!');
 }
开发者ID:tyloo,项目名称:tyloo,代码行数:32,代码来源:SitemapCommand.php

示例9: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker::Create();
     foreach (range(1, 10) as $seededItem) {
         User::create(['first_name' => $faker->name, 'last_name' => $faker->name, 'password' => Hash::make('123456'), 'type' => false, 'sex' => $faker->boolean(), 'email' => $faker->email, 'date_of_birth' => $faker->date('Y-m-d')]);
     }
     $users = User::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Post::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0]);
     }
     $posts = Post::all()->lists('id')->toArray();
     Comment::create(['user_id' => $faker->randomElement($users), 'body' => $faker->text, 'vote_count' => 0, 'parent_id' => null]);
     foreach (range(1, 100) as $seededItem) {
         Post_Vote::create(['user_id' => $faker->randomElement($users), 'post_id' => $faker->randomElement($posts), 'up' => $faker->boolean()]);
         Comment::create(['user_id' => $faker->randomElement($users), 'parent_id' => $faker->randomElement(Comment::all()->lists('id')->toArray()), 'post_id' => $faker->randomElement($posts), 'body' => $faker->text, 'vote_count' => 0]);
         Tag::create(['name' => $faker->text, 'private' => $faker->boolean()]);
     }
     $comments = Comment::all()->lists('id')->toArray();
     $tags = Tag::all()->lists('id')->toArray();
     foreach (range(1, 100) as $seededItem) {
         Comment_Vote::create(['user_id' => $faker->randomElement($users), 'comment_id' => $faker->randomElement($comments), 'up' => $faker->boolean()]);
         Tag_User::create(['user_id' => $faker->randomElement($users), 'tag_id' => $faker->randomElement($tags)]);
         Post_Tag::create(['tag_id' => $faker->randomElement($tags), 'post_id' => $faker->randomElement($posts)]);
     }
 }
开发者ID:khaled-barca,项目名称:MyTunnelVision,代码行数:30,代码来源:TableSeeder.php

示例10: index

 public function index()
 {
     /**
      * Loading all posts.
      */
     $posts = Post::all();
     return view('blog.list', compact('posts'));
 }
开发者ID:kzoty,项目名称:blog-laravel,代码行数:8,代码来源:PostsController.php

示例11: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $user = Auth::user();
     $posts = Post::all();
     $data = $request->all();
     Post::create(['content' => $data['content'], 'user_id' => $user->id]);
     return view('wall.index', compact('user', 'posts', 'data'));
 }
开发者ID:sammyboy45467,项目名称:Skynet_for_users,代码行数:14,代码来源:WallController.php

示例12: last

 public function last($n = 3)
 {
     $posts = Post::all()->with(['tags' => function ($q) {
         $q->select('id', 'title');
     }])->with(['comments' => function ($q) {
         $q->active()->select('active', 'post_id');
     }])->orderBy('id', 'desc')->take($n)->get();
 }
开发者ID:petrovitch,项目名称:chess,代码行数:8,代码来源:PostsController.php

示例13: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $posts = Post::all();
     if (!empty($posts)) {
         return response()->json(array('error' => false, 'posts' => $posts), 200);
     } else {
         return response()->json(array('error' => false, 'posts' => 'No posts found.'), 200);
     }
 }
开发者ID:amitmerchant1990,项目名称:TestApiLaravel,代码行数:14,代码来源:PostController.php

示例14: posts

 public function posts(Request $req)
 {
     $content = [];
     $content['count'] = count(Post::all());
     $content['page'] = 2;
     $content['per_page'] = 10;
     $content['data'] = Post::all();
     return response($content, Response::HTTP_OK)->withHeaders(['Content-Type' => 'application/json', 'Access-Control-Allow-Origin' => '*']);
 }
开发者ID:zachjamesgreen,项目名称:newyogaadmin,代码行数:9,代码来源:Posts.php

示例15: getContent

 public function getContent()
 {
     if (!Auth::check()) {
         return redirect('/login')->with('error', 'You need to be logged in!');
     }
     $media = Post::all();
     $comments = Comment::all();
     return view('blog.content', compact('media', "comments"));
 }
开发者ID:ChristofVanoppen,项目名称:PHP2-MiniCMS,代码行数:9,代码来源:PostController.php


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