Exemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  * @param CreateCommentRequest $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCommentRequest $request)
 {
     //validation
     //$input = Request::all();
     Comment::create($request->all());
     return redirect('comment');
 }
 /**
  * Updates the comment for the given project
  *
  * @param $request = user entered text, $projectComment = data
  * @return view Back to the same page
  */
 public function updateComment(CreateCommentRequest $request, ProjectComment $projectComment)
 {
     $this->authorize('userIsOwner', $projectComment);
     $projectComment->update($request->all());
     $projectPath = 'project/' . $projectComment->project->title;
     return redirect($projectPath);
 }
 /**
  * Store a newly created Comment in storage.
  *
  * @param CreateCommentRequest $request
  *
  * @return Response
  */
 public function store(CreateCommentRequest $request)
 {
     $input = $request->all();
     $comment = $this->commentRepository->create($input);
     Flash::success('Comment saved successfully.');
     return redirect(route('comments.index'));
 }
 /**
  * Store a newly created Comment in storage.
  *
  * @param CreateCommentRequest $request
  *
  * @return Response
  */
 public function store(CreateCommentRequest $request)
 {
     $input = $request->all();
     //        dd($input);
     $input['user_id'] = Auth::user()->id;
     $comment = $this->commentRepository->store($input);
     Flash::message('Comment saved successfully.');
     return back();
 }
Exemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function storeComment(Comments $comment, CreateCommentRequest $request)
 {
     /*$this->validate($request, [
     			'nama' => 'required',
     			'email' => 'required|email',
     			'komentar' => 'required'
     		]);*/
     $news_slug = News::where('id', $request->input('news_id'))->first()->slug;
     $comment->create($request->all());
     return redirect()->route('news_path', [$news_slug, '#comments-box']);
 }
Exemplo n.º 6
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCommentRequest $request, $task_id)
 {
     $task = Task::findOrFail($task_id);
     $comment = new Comment();
     $comment->fill($request->all());
     $comment->task_id = $task->id;
     $comment->user_id = \Auth::user()->id;
     $comment->save();
     $comment->user;
     return $comment;
 }
Exemplo n.º 7
0
 public function storeComment(Requests\CreateCommentRequest $request)
 {
     $user_id = Sentinel::getUser()->id;
     $lastest = PostService::getLatestSubmit($user_id);
     if (diff_timestamp($lastest->created_at) < 1 * 60) {
         return redirect()->back()->with('error', '도배 방지를 위해, 1분 이내에 글을 연속적으로 작성하실 수 없습니다.');
     }
     $post = PostService::createComment($request->all());
     if ($post->parent_on == 'problem') {
         return redirect()->route('problems.show', $post->parent_id);
     }
     return redirect()->route('posts.show', $post->parent_id);
 }
Exemplo n.º 8
0
 public function actionCreate(Requests\CreateCommentRequest $request)
 {
     // Create a new model instance and populate it with the request.
     $comment = new Comment($request->all());
     // Find in the database the photo sent with the request.
     $photo = Photo::findOrFail($request->input('photo_id'));
     // Attach the comment to the photo.
     $comment = $photo->comments()->save($comment);
     // Save the comment in the database.
     Auth::user()->comments()->save($comment);
     // Redirect with flash message.
     \Session::flash('flash_message', 'You have successfully commented on a photo.');
     return json_encode($comment);
 }
 public function update(CreateCommentRequest $request, $id)
 {
     $comment = $this->comment;
     $comment->user_id = $request->get('name');
     $comment->content = $request->get('content');
     $comment->project_id = $id;
     $comment->save();
     $project = Project::whereId($id)->first();
     $slug = $project->slug;
     $task = new Task();
     $tasks = $task->whereProject_id($id)->orderBy('id', 'desc')->first();
     //return view('projects.show', ['project' => $project, 'task' => $tasks]);
     return redirect()->route('projects.show', ['slug' => $slug, 'task' => $tasks]);
 }
Exemplo n.º 10
0
 /**
  * Store a newly created resource in storage.
  *
  * @param $id
  * @param CreateCommentRequest $request
  * @return \Illuminate\Http\RedirectResponse|string
  */
 public function store($id, CreateCommentRequest $request)
 {
     $lesson = Lesson::findOrFail($id);
     $comment = new Comment();
     $comment->fill($request->all());
     $comment->user_id = Auth::user()->id;
     $comment->lesson_id = $lesson->id;
     $comment->save();
     $message = trans('messages.comment_successfully_submitted');
     if ($request->ajax()) {
         return $message;
     }
     Flash::success($message);
     return redirect()->route('lessons.show', $lesson->id);
 }
Exemplo n.º 11
0
 public function postEditComment(CreateCommentRequest $request, $id)
 {
     try {
         $comment = Comment::findOrFail($id);
         // asume the use always has a profile.
         $profile_image_name = Profile::whereUserId($request->user()->id)->pluck('profile_image_name');
         if ($comment && $comment->comment_author_id == Auth::user()->id) {
             $comment->body = $request->get('body');
             $comment->updated_at = Carbon::now();
             $comment->save();
             return response()->json(array('message' => 'Your Comment has been updated', 'status' => 'success', 'body' => $comment->body, 'user_id' => Auth::id(), 'profile_image_name' => $profile_image_name, 'comment_id' => $comment->id, 'nickname' => $request->user()->nickname, 'comment_author_id' => $comment->comment_author_id));
         }
     } catch (ModelNotFoundException $e) {
         return response()->json(array('message' => 'Unauthorized attempt to update comment', 'status' => 'failed'));
     }
 }
Exemplo n.º 12
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(CreateCommentRequest $request, Post $post)
 {
     //$post = Post::find($request->post_id);
     ////$comment = new Comment;
     ////$comment->comment = $request->comment;
     ////$comment->user_id = auth()->user()->id;
     //$comment = new Comment(['comment' => $request->comment, 'user_id' => auth()->user()->id]);
     //$post->comments()->save($comment);
     // $post->comments()->save(
     //     new Comment(['comment' => $request->comment, 'user_id' => auth()->user()->id]);
     // );
     //$post->comments()->create(['comment' => $request->comment,
     //                            user_id' => auth()->user()->id]);
     // $post->addComment(
     //     new Comment(['comment' => $request->comment, 'user_id' => auth()->user()->id])
     // );
     $comment = new Comment($request->all());
     $post->addComment($comment, auth()->user()->id);
     return back();
 }
 /**
  * Update the specified Comment in storage.
  *
  * @param  int    $id
  * @param CreateCommentRequest $request
  *
  * @return Response
  */
 public function update($id, CreateCommentRequest $request)
 {
     $comment = $this->commentRepository->findCommentById($id);
     if (empty($comment)) {
         Flash::error('Comment not found');
         return redirect(route('comments.index'));
     }
     $comment = $this->commentRepository->update($comment, $request->all());
     Flash::message('Comment updated successfully.');
     return redirect(route('comments.index'));
 }