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