示例#1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function newComment(CommentFormRequest $request)
 {
     $user_id = Auth::user()->id;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
     $comment->save();
     return redirect()->back()->with('custom_success', 'Your comment has been created!');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $comentario = new Comment($request->all());
     //        dd($comentario);
     $comentario->save();
     return redirect()->back();
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Comment $comment)
 {
     $comment->deleted_at = \Carbon\Carbon::now();
     if ($comment->save()) {
         return $this->respondWithItem($comment, new CommentTransformer());
     }
 }
示例#4
0
 public function addComment(Request $request)
 {
     $replyid = '';
     $rules = ['comment' => 'required|min:10'];
     $v = Validator::make($request->all(), $rules);
     if ($v->fails()) {
         $return['status'] = false;
         $return['errors'] = $v->errors();
     } else {
         $comment = new Comment();
         $comment->user_id = $this->user->id;
         if ($request->has('reply_id')) {
             $replyid = $request->get('reply_id');
             $comment->reply_id = $replyid;
         }
         $comment->item_id = $request->get('item_id');
         $comment->type = $request->get('type');
         $comment->comment = $request->get('comment');
         $comment->status = 1;
         $comment->save();
         $commentView = view('modules.comment.item', ['comment' => $comment, 'type' => $comment->type, 'item_id' => $comment->item_id])->render();
         $return['status'] = true;
         $return['view'] = $commentView;
         $return['replyid'] = $replyid;
     }
     return $return;
 }
示例#5
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, RentalUnit $rentalUnit)
 {
     $newComment = new Comment();
     $newComment->fill(Input::all());
     $newComment->save();
     return Response::json($newComment);
 }
 public function store(Requests\SaveCommentRequest $request, $offer_id)
 {
     $offer = Offer::findOrFail($offer_id);
     if (Gate::denies('add-comment', $offer)) {
         abort(403);
     }
     $comment = new Comment();
     $comment->fill($request->input());
     $comment->user_id = Auth::user()->id;
     $comment->offer_id = $offer_id;
     $comment->save();
     $violation = $offer->violation;
     // Send email
     $user_type = Auth::user()->getOriginal('user_type');
     if ($user_type == 'cus') {
         $to = $offer->author->username;
         $email = $offer->author->email;
     } else {
         $to = $violation->author->username;
         $email = $violation->author->email;
     }
     $poster_name = Auth::user()->username;
     $address = $violation_name = $violation->address1 . ', ' . $violation->city . ' (' . $violation->getOriginal('state') . ') ' . $violation->zip;
     $data = compact('user_type', 'to', 'poster_name', 'address', 'offer_id');
     Mail::send('emails.newcomment', $data, function ($message) use($email) {
         $message->subject('New Comment Posted');
         $message->to($email);
     });
     // Flash message
     Session::flash('message', 'Your comment has been posted to the offer.');
     Session::flash('message-type', 'success');
     // Redirect
     return redirect(url('/offer/' . $offer_id . '#comment_' . $comment->id));
 }
示例#7
0
 public function saveComment(Request $request)
 {
     $validator = Validator::make($request->all(), ['name' => 'required|min:3|max:60', 'email' => 'required|min:8|max:60', 'comment' => 'required|min:5|max:2000', 'equal' => 'required|min:1|max:2']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     list(, $first_number) = explode('_', $request->type_1);
     list(, $second_number) = explode('_', $request->type_2);
     $equal = (int) $first_number + (int) $second_number;
     if ($equal != $request->equal) {
         return redirect()->back()->withErrors(['Уравнение не верно!'])->withInput();
     }
     $url = explode('/', URL::previous());
     $id = end($url);
     if ($request->id === $id and $request->type === 'post') {
         $comment = new Comment();
         $comment->parent_id = $request->id;
         $comment->parent_type = 'App\\Post';
         $comment->name = $request->name;
         $comment->email = $request->email;
         $comment->comment = $request->comment;
         $comment->save();
         return redirect()->back()->with('status', 'Комментарии добавлен!');
     } else {
         return redirect()->back()->with('status', 'Ошибка!');
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id, Request $request)
 {
     $comment = new Comment();
     $comment->news_id = $request->input('news_id');
     $comment->fill($request->all());
     $comment->save();
     return Redirect::back();
 }
 public function abeet()
 {
     $comment = new Comment();
     $comment->name = \Auth::user()->name;
     $comment->comment = \Request::input('comment');
     $comment->save();
     return redirect('/');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     //
     $comment = new Comment();
     $comment->author = $request->input("author");
     $comment->comment = $request->input("comment");
     $comment->save();
     return $comment;
 }
示例#11
0
 public function store(CommentRequest $request, Comment $comment)
 {
     $comment->fill($request->all());
     $comment->user_id = Auth::user()->id;
     $comment->save();
     $activity = 'Commented on a ' . ucfirst($request->input('belongs_to'));
     Activity::log($activity);
     return redirect()->back()->withSuccess(config('constants.SAVED'));
 }
示例#12
0
 public function store(Request $request)
 {
     \Log::info($request->input('author'));
     $comment = new Comment();
     $comment->content = $request->input('content');
     $comment->author = $request->input('author');
     $comment->save();
     return $comment->toArray();
 }
 public function saveComment(Request $request, $id)
 {
     $article = Article::findOrFail($id);
     $comment = new Comment($request->all());
     $comment->user_id = Auth::user()->id;
     $comment->article_id = $id;
     $comment->save();
     return redirect('articles/' . $id);
 }
示例#14
0
 public function create($id)
 {
     $input = Request::all();
     $comment = new Comment();
     $comment->post_id = $id;
     $comment->body = $input['body'];
     $comment->save();
     return redirect('/posts/' . $id);
 }
示例#15
0
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['body' => 'required']);
     $comment = new Comment();
     $comment->body = $request->input("body");
     $comment->blog_id = $request->input("blog_id");
     $comment->save();
     return redirect()->route('blogs.show', ['id' => $comment->blog_id])->with('message', 'Item created successfully.');
 }
 public function comment(CommentRequest $request)
 {
     $comment = new Comment();
     $comment->user_id = Auth::user()->id;
     $comment->lecture_id = $request->id;
     $comment->comment = $request->comment;
     $comment->save();
     return redirect::back();
 }
示例#17
0
 public function saveComment(Request $request)
 {
     $comment = new Comment();
     $comment->message = $request->input('message');
     $comment->post_id = $request->input('post_id');
     $comment->user_id = Auth::id();
     $comment->save();
     return response()->json($comment);
 }
示例#18
0
 /**
  * Function create comment
  * @author  Tran Van Moi <[moitran92@gmail.com]>
  * @since  2015/05/13
  * @param  string $content
  * @param  int $post_id
  * @return object
  */
 public static function create_cmt($content, $post_id)
 {
     $cmt = new Comment();
     $cmt->user_id = Auth::user()->id;
     $cmt->post_id = $post_id;
     $cmt->content = $content;
     $cmt->save();
     return $cmt;
 }
示例#19
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $comment = new App\Comment();
     $comment->user_id = \Auth::user()->id;
     $comment->comment_id = $request->comment_id;
     $comment->post_id = $request->post_id;
     $comment->comment_content = $request->comment_content;
     $comment->save();
     return $comment;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $comment = new Comment();
     $comment->c_email = $request->email;
     $comment->c_message = $request->message;
     $comment->post_id = $request->idPost;
     $comment->c_spam = 0;
     $comment->save();
     return redirect()->back()->withInput();
 }
示例#21
0
 public function newComment(CommentFormRequest $request)
 {
     $content = $request->get('content');
     $content = preg_replace('/ /', '&nbsp', $content);
     $content = preg_replace('/\\n/', '<br>', $content);
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $content));
     $comment->save();
     //        return redirect()->back()->with('status', 'Your comment has been created!');
     return redirect()->to(URL::previous() . "#comment");
 }
示例#22
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CommentsFormRequest $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(CommentsFormRequest $request)
 {
     $new_comment = new Comment();
     $new_comment->user_id = Auth::user()->id;
     $new_comment->article_id = $request->article_id;
     $new_comment->body = $request->body;
     $new_comment->save();
     \Session::flash('flash_message', 'Comment Succeed!');
     return redirect()->route('articles.show', [$request->article_id]);
 }
 public function store(Request $request)
 {
     $rules = ['author' => 'required|max:50', 'text' => 'required|unique:comments,text|max:255'];
     $this->validate($request, $rules);
     $comment = new Comment();
     $comment->author = $request->author;
     $comment->text = $request->text;
     $comment->save();
     return $comment;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Requests\CommentRequest $request)
 {
     $this->authorize('createComment', \Auth::user());
     $comment = new Comment();
     $comment->user_id = \Auth::user()->id;
     $comment->article_id = $request->article_id;
     $comment->body = $request->body;
     $comment->save();
     return back()->with('flash_success', 'Комментарий успешно отправлен.');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($id)
 {
     $request = Request::all();
     $comment = new Comment();
     $comment->user()->associate(Auth::user()->id);
     $comment->article()->associate($request['articleID']);
     $comment->comment = $request['comment'];
     $comment->save();
     return redirect('/articles/' . $request['articleID']);
 }
示例#26
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $comment = new Comment();
     $comment->body = $request->body;
     $comment->post_id = $request->post_id;
     $comment->user_id = Auth::user()->id;
     $comment->save();
     $post = Post::where('id', $request->post_id)->get();
     return Redirect($post[0]->community_id . '/post/' . $request->post_id)->with('message', 'Post created');
 }
 /**
  * 评论
  * @return bool
  */
 public function comments(Request $request)
 {
     $comment = new Comment();
     $comment->content = $request->content;
     $comment->message_id = $request->message_id;
     $comment->user_id = Auth::id();
     $comment->message_user_id = Message::find($request->message_id)['user_id'];
     $comment->save();
     return Redirect('/message_info' . '/' . $request->message_id);
 }
 public function newComment(Request $request)
 {
     $this->validate($request, ['comment' => 'required|min:2|max:140', 'tweet_id' => 'required|exists:tweets,id']);
     $comment = new Comment();
     $comment->content = $request->comment;
     $comment->user_id = \Auth::user()->id;
     $comment->tweet_id = $request->tweet_id;
     $comment->save();
     // redirects user back to page.
     return back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  * @return Response
  */
 public function postComment(Request $request, $id)
 {
     $this->validate($request, ['content' => 'required']);
     $comment = new Comment();
     $comment->content = $request->input('content');
     $comment->nickname = $this->_user->username;
     $comment->email = $this->_user->email;
     $comment->article_id = $id;
     $comment->save();
     return Redirect::back();
 }
示例#30
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function saveComment($id, Request $request)
 {
     $postComment = $request->input('comment');
     $user_id = Auth::user()->id;
     $comment = new Comment();
     $comment->comment = $postComment;
     $comment->user_id = $user_id;
     $comment->product_id = $id;
     $comment->save();
     return redirect('product/' . $id . '/view');
 }