当前位置: 首页>>代码示例>>PHP>>正文


PHP Comment::save方法代码示例

本文整理汇总了PHP中app\Comment::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Comment::save方法的具体用法?PHP Comment::save怎么用?PHP Comment::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Comment的用法示例。


在下文中一共展示了Comment::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: newComment

 /**
  * 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!');
 }
开发者ID:ErtyGi,项目名称:wsapp,代码行数:12,代码来源:CommentsController.php

示例2: store

 /**
  * 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();
 }
开发者ID:RudyEscalera,项目名称:examenfinal,代码行数:12,代码来源:CommentsController.php

示例3: destroy

 /**
  * 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());
     }
 }
开发者ID:jasonb8293,项目名称:fox-api,代码行数:13,代码来源:CommentController.php

示例4: addComment

 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;
 }
开发者ID:sordev,项目名称:bootup,代码行数:27,代码来源:CommentController.php

示例5: store

 /**
  * 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);
 }
开发者ID:VJan-fin,项目名称:Roomie,代码行数:13,代码来源:CommentController.php

示例6: store

 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));
 }
开发者ID:softelos,项目名称:app.buildingviolation.com,代码行数:34,代码来源:CommentController.php

示例7: saveComment

 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', 'Ошибка!');
     }
 }
开发者ID:vizovteam,项目名称:vizov,代码行数:27,代码来源:CommentController.php

示例8: store

 /**
  * 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();
 }
开发者ID:nikajorjika,项目名称:gamoiwere.ge,代码行数:14,代码来源:CommentController.php

示例9: abeet

 public function abeet()
 {
     $comment = new Comment();
     $comment->name = \Auth::user()->name;
     $comment->comment = \Request::input('comment');
     $comment->save();
     return redirect('/');
 }
开发者ID:GoobyeEarth,项目名称:abetter,代码行数:8,代码来源:CommentsController.php

示例10: store

 /**
  * 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;
 }
开发者ID:berkayk,项目名称:react-laravel-comment-demo-app,代码行数:15,代码来源:CommentController.php

示例11: store

 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'));
 }
开发者ID:EneaWeb,项目名称:aliangel,代码行数:9,代码来源:CommentController.php

示例12: store

 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();
 }
开发者ID:HoangTuBe,项目名称:react,代码行数:9,代码来源:CommentController.php

示例13: saveComment

 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);
 }
开发者ID:pexea12,项目名称:uethackathon2015_team10server,代码行数:9,代码来源:ArticlesController.php

示例14: create

 public function create($id)
 {
     $input = Request::all();
     $comment = new Comment();
     $comment->post_id = $id;
     $comment->body = $input['body'];
     $comment->save();
     return redirect('/posts/' . $id);
 }
开发者ID:erzhu4,项目名称:larvelProject,代码行数:9,代码来源:CommentsController.php

示例15: store

 /**
  * 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.');
 }
开发者ID:alnutile,项目名称:demo,代码行数:15,代码来源:CommentController.php


注:本文中的app\Comment::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。