/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Requests\StoreCommentRequest $request) { if (Comment::create($request->all())) { return Redirect::back(); } else { return Redirect('/'); } }
public function store(StoreCommentRequest $request) { // TODO: findOrFail ile kontrol et. ModelNotFoundException'ı handle'a ekle. if (!Log::find($request->log_id)) { return redirect()->back(); } // TODO: Bu işlemi CommentObserver'da yap. $request->merge(['user_id' => auth()->user()->id]); Comment::create($request->all()); return redirect()->back(); }
/** * 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(); }
public function store_comment(StoreCommentRequest $request, $id) { $article = $this->article_by_path($id); $article->comments()->create(['username' => $request->get('username'), 'body' => $request->get('body')])->notify_admin($article); return redirect($request->fullUrl()); }