Esempio n. 1
0
 public function destroyComments(Request $request, $id)
 {
     $comment = Comments::find($id);
     $comment->delete();
     $request->session()->flash('alert-success', 'Комментарий удалён!');
     return redirect('content/comments');
 }
Esempio n. 2
0
 public function storeComment(Request $request, $id)
 {
     $product = Products::find($id);
     $validator = Validator::make($request->all(), ['name' => 'required|min:2|max:120', 'email' => 'required|email', 'msg' => 'required|min:5', 'captcha' => 'required|captcha']);
     if ($validator->fails()) {
         return redirect($product->urlhash . '.html#comment')->withErrors($validator)->withInput();
     } else {
         $comment = new Comments();
         $comment->name = $request->name;
         $comment->email = $request->email;
         $comment->msg = $request->msg;
         $comment->product_id = $product->id;
         $comment->save();
         $request->session()->flash('alert-success', 'Комментарий отправлен и будет обработан после модерации!');
         return redirect($product->urlhash . '.html#comment');
     }
 }