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


PHP Comment::all方法代码示例

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


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

示例1: index

 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,代码行数:7,代码来源:HomeController.php

示例2: 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

示例3: show

 /**
  * Display the specified content.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $content = Content::findOrFail($id);
     $uploader = User::find($content->user_id);
     $comments = Comment::all()->where('content_id', '=', $id);
     return view('content.detail', compact('content', 'uploader', 'comments'));
 }
开发者ID:PieterVDE,项目名称:PieterCMS2,代码行数:13,代码来源:ContentController.php

示例4: index

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

示例5: index

 public function index(Manager $fractal, CommentTransformer $commentTransformer)
 {
     // show all
     $records = Comment::all();
     $collection = new Collection($records, $commentTransformer);
     $data = $fractal->createData($collection)->toArray();
     return $this->respond($data);
 }
开发者ID:wyrover,项目名称:lenda-api,代码行数:8,代码来源:CommentsController.php

示例6: getContent

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

示例7: index

 /**
  * Display a listing of the comment.
  *
  * @return Response
  */
 public function index()
 {
     // Get all the comments
     $comments = Comment::all();
     // Initialise view parameters
     $params = ['title' => 'All Comments', 'comments' => $comments];
     // Return the rendered view
     return view('blog.comment.index', $params);
 }
开发者ID:ambarsetyawan,项目名称:gday-laravel,代码行数:14,代码来源:CommentController.php

示例8: getCommentsByPostId

 /**
  * Get list comment by post_id
  *
  * @param $post_id
  *
  * @return null
  */
 public static function getCommentsByPostId($post_id)
 {
     $comments = Comment::all()->where('post', intval($post_id));
     if ($comments->count() == 0) {
         return [];
     }
     $listComments = [];
     foreach ($comments as $comment) {
         $listComments[] = Comment::getCommentInfoById($comment->id);
     }
     return $listComments;
 }
开发者ID:uethackathon,项目名称:uethackathon2015_team2server,代码行数:19,代码来源:Comment.php

示例9: dashboard

 /**
  * Show the admin dashboard
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function dashboard(Request $request)
 {
     $posts = Post::all()->groupBy('post_type')->toArray();
     if (!array_key_exists('post', $posts)) {
         $posts["post"] = [];
     }
     if (!array_key_exists('page', $posts)) {
         $posts["page"] = [];
     }
     $comments = Comment::all()->count();
     return view('admin.dashboard', ['posts' => $posts, 'comment_count' => $comments]);
 }
开发者ID:DrizzlyOwl,项目名称:drizzlyowl.co.uk,代码行数:18,代码来源:AdminController.php

示例10: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $users = User::all();
     $count = $users->count();
     $projects = Project::all();
     $comments = Comment::all();
     $categories = Category::all();
     $backers = Backer::all();
     $creators = Creator::all();
     $commentLast = Comment::all()->take(4);
     return view('Admin.index', compact('creators', 'count', 'projects', 'comments', 'categories', 'backers', 'commentLast'));
 }
开发者ID:Elbar,项目名称:InvestMe,代码行数:17,代码来源:AdminController.php

示例11: index

 public function index()
 {
     $date1 = date('Y/m/d ') . ' 00:00:00';
     $date2 = date('Y/m/d ') . ' 23:59:59';
     $idComments = Comment::all()->lists('id');
     $comment5 = Comment::select()->orderBy('created_at', 'desc')->limit(5)->get();
     $commentsToday = Comment::select()->where('type', '<>', 'Error')->whereBetween('created_at', [$date1, $date2])->get();
     $commentWithAnswer = Comment::select()->where('type', '=', 'Error')->get();
     $commentWithAnswerToday = AnswerComment::select()->whereBetween('created_at', [$date1, $date2])->get();
     $totalComments = sizeof($idComments);
     $totalcWa = sizeof($commentWithAnswer);
     $totalcWNa = $totalComments - $totalcWa;
     $totalCommentsToday = sizeof($commentsToday);
     $totalCommentsWithAnswerToday = sizeof($commentWithAnswerToday);
     return view('index', compact('totalcWa', 'totalcWNa', 'comment5', 'totalCommentsToday', 'totalCommentsWithAnswerToday'));
 }
开发者ID:ReyesPedro,项目名称:Proyecto-de-grado,代码行数:16,代码来源:DashBoardController.php

示例12: getCommentsCount

 public function getCommentsCount()
 {
     $comments = Comment::all();
     if (!$comments) {
         return CommentHelpers::formatData(array(), FALSE);
     }
     $commentData = [];
     foreach ($comments as $comment) {
         if (!isset($commentData[$comment->slug])) {
             $commentData[$comment->slug] = 1;
         } else {
             $commentData[$comment->slug]++;
         }
     }
     return CommentHelpers::formatData(array($commentData));
 }
开发者ID:flowersw,项目名称:squabble,代码行数:16,代码来源:CommentController.php

示例13: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     /* Probably needs to be updated to NOT truncate User, so contributors pulling down and going through the ReadMe can first create a user, and then seed (allowing the seed to randomly generate posts, comments and subscriptions for the created user first) */
     User::truncate();
     Post::truncate();
     Comment::truncate();
     Subbreddit::truncate();
     DB::table('subbreddit_user')->truncate();
     $users = factory(User::class, 25)->create();
     $users->each(function ($user) {
         $user->subbreddits()->save(factory(App\Subbreddit::class)->make());
         $user->posts()->save(factory(App\Post::class)->make(['subbreddit_id' => rand(1, App\Subbreddit::all()->count())]));
         $user->comments()->save(factory(App\Comment::class)->make(['post_id' => rand(1, App\Post::all()->count())]));
         $user->comments()->save(factory(App\Comment::class)->make(['comment_id' => rand(1, App\Comment::all()->count())]));
         $user->subscribedSubbreddits()->attach(rand(1, App\Subbreddit::all()->count()));
     });
 }
开发者ID:nickdunn2,项目名称:breddit,代码行数:22,代码来源:DatabaseSeeder.php

示例14: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $comments = \App\Comment::all();
     $fake_replies = file_get_contents("http://jsonplaceholder.typicode.com/comments");
     $fake_replies = json_decode($fake_replies, true);
     foreach ($comments as $comment) {
         if (mt_rand(0, 1)) {
             $replies = \App\Reply::where('reply_to_id', $comment->id)->get();
             if (count($replies) > 0) {
                 continue;
             } else {
                 $reply = new \App\Reply();
                 $reply->reply_to_id = $comment->id;
                 $one_reply = $fake_replies[mt_rand(0, count($fake_replies) - 1)];
                 $reply->reply_text = $one_reply['body'];
                 $reply->save();
             }
         }
     }
 }
开发者ID:benpbrown,项目名称:cmpe332-site,代码行数:25,代码来源:RepliesTableSeeder.php

示例15: index

 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     /*
             $comments = Comment::all();
             $json = array();
             foreach($comments as $comment){
                 $user_from = $comment->userFrom()->first();
                 $user_to = $comment->userTo()->first();
     
                 $user_from_json = array('id'=>$user_from->facebook_id, 'name'=>$user_from->name);
                 $user_to_json = array('id'=>$user_to->facebook_id, 'name'=>$user_to->name);
     
                 $json[] = array(
                 	'comment' => $comment->comment,
                     'userFrom' => $user_from_json, 'userTo'=>$user_to_json,
                     'created_at' => $comment->created_at, 'updated_at' => $comment->updated_at
                 );
             }*/
     // Note: serialization will take care of it.
     return response()->json(Comment::all());
 }
开发者ID:kelsie1231,项目名称:StalkyServerSide,代码行数:26,代码来源:CommentController.php


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