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); }
/** * 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)]); } }
/** * 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')); }
public function index() { if (\Request::ajax()) { return Comment::all(); } return view('comment.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); }
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')); }
/** * 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); }
/** * 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; }
/** * 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]); }
/** * 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')); }
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')); }
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)); }
/** * 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())); }); }
/** * 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(); } } } }
/** * 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()); }
public function random() { $form = Form::all(); $first = $form->first(); $last = $form->last(); do { $id = mt_rand($first->id, $last->id); $forms = Form::find($id); } while (!$forms); Form::find($forms->id)->increment('views'); $comments = Comment::all(); $users = User::all(); $user = \Auth::user(); $likes = Like::all(); foreach ($users as $formuser) { if ($forms->user_id == $formuser->id) { $username = $formuser->name; $userlastname = $formuser->lastname; $userid = $formuser->id; } } $likedata = $this->countLikes($likes, $forms); $likesamount = $likedata['likesamount']; $likesis = $likedata['likesis']; return view('form.show', compact('forms'), compact('comments', 'likesis', 'likesamount', 'user', 'username', 'userlastname', 'userid')); }
/** * Send back all comments as JSON * * @return Response */ public function index() { $comments = Comment::all(); return Response::json($this->transformCollection($comments)); }
public function index() { return view('admin.comments.index')->with('comments', Comment::all()); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(StoreCommentRequest $request) { $comment = new Comment($request->all()); $comment->save(); return Comment::all(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $comments = Comment::all(); $nested = $this->buildTree($comments->toArray()); return response()->json($nested); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $comment = Comment::all(); //dd($comment); return view('comment.index', compact('comment')); }
public function run() { // Disables foreign key constraints DB::statement('SET FOREIGN_KEY_CHECKS = 0'); $faker = Faker\Factory::create(); $posts = DB::table('posts')->get(); Comment::truncate(); foreach (range(1, 50) as $index) { $post = $faker->randomElement($posts); Comment::create(['post_id' => $post->id, 'author' => $faker->name(), 'email' => $faker->optional(0.9, '')->email(), 'content' => $faker->sentence(3), 'created_at' => $faker->dateTimeBetween($post->created_at, '1 day ago')]); } // All root comments $parent_comments = Comment::all()->lists('id'); // Generating random lvl of comments foreach (range(1, 40) as $index) { $comment = $faker->randomElement(DB::table('comments')->select('id', 'created_at', 'post_id')->get()); Comment::create(['post_id' => $comment->post_id, 'parent_id' => $comment->id, 'author' => $faker->name(), 'email' => $faker->email(), 'content' => $faker->sentence(2), 'created_at' => $faker->dateTimeBetween($comment->created_at, '1 days ago')]); } // Enables foreign key constraints DB::statement('SET FOREIGN_KEY_CHECKS = 1'); }
/** * Return all comments sort by $filter * * @param $filter * @return \Illuminate\View\View */ private function changeFilter($filter) { if ($filter == 'all') { $comments = Comment::all()->sortByDesc('created_at'); } else { $comments = Comment::all()->sortByDesc('created_at')->where('status', $filter); } return view('dashboard.partials.comment.index', compact('comments')); }
public function index() { $comments = Comment::all(); return $this->success($comments, 200); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $comments = Comment::all(); return view('comment.index', compact('comments')); }
public function index() { return Comment::all()->toArray(); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { return \App\Comment::all(); }
public function getId($id) { $users = User::all(); $user = $this->getUser(); $curr_event = Event::where('id', $id)->first(); $all_comm = Committee::all(); $committees = Committee::where('event_id', $curr_event->id)->get(); $comm_array = Committee::where('event_id', $curr_event->id)->get(array('id'))->toArray(); $events = Event::all(); $tasks = Task::where('assigned_to', $user['id'])->whereIn('comm_id', $comm_array)->get(); //tasks assigned to current user $all_tasks = Task::all(); $categories = array('Pending', 'In-progress', 'Delayed', 'Finished'); $comments = Comment::all(); //get current event id $curr_event_id = $curr_event->id; //check if current user is upper head //get all heads of current event $heads = Head::where('event_id', $curr_event_id)->where('user_id', $user->id)->get(); //get all comm_id(as array) in the current event where current user is a head $heads_comm = Head::where('event_id', $curr_event_id)->where('user_id', $user['id'])->get(array('comm_id'))->toArray(); //members of committee $mem = Member::whereIn('comm_id', $heads_comm)->get(array('user_id'))->toArray(); $members = User::whereIn('id', $mem)->get(); //get all committees in the current event where current user is a head $head_committees = Committee::whereIn('id', $heads_comm)->get(); //current user is a head $heads_comm = Head::where('user_id', $user['id'])->get(); //committees where current user is a member $mem_comm = Member::where('user_id', $user['id'])->get(); $url = "pages/profile"; //check if curret user is admin if ($user->id == 1) { return redirect('/admin/'); } //check if current user is OAH if ($curr_event->oah_id == $user->id) { $url = "pages/oah"; } //return heads page if user is lower head if ($heads != "[]") { $url = "pages/heads"; } if ($user->standing == "unconfirmed") { $url = "pages/oops"; } echo $url; return view($url, compact('users', 'user', 'events', 'curr_event', 'all_comm', 'committees', 'tasks', 'all_tasks', 'categories', 'comments', 'head_committees', 'heads_comm', 'mem_comm', 'members')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // return view('admin.comments.index')->withComments(Comment::all()); }
public function comments() { $comments = Comment::all(); return view('pages.comments')->with('comments', $comments)->with('user_id', \Session::get('user_id')); }