本文整理汇总了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);
}
示例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)]);
}
}
示例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'));
}
示例4: index
public function index()
{
if (\Request::ajax()) {
return Comment::all();
}
return view('comment.index');
}
示例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);
}
示例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'));
}
示例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);
}
示例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;
}
示例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]);
}
示例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'));
}
示例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'));
}
示例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));
}
示例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()));
});
}
示例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();
}
}
}
}
示例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());
}