Beispiel #1
0
 public function comment(\Illuminate\Http\Request $request)
 {
     $validator = \Illuminate\Support\Facades\Validator::make($request->all(), ['name' => 'required', 'email' => 'required', 'text' => 'required']);
     if ($validator->fails()) {
         return redirect('home')->withErrors($validator)->withInput();
     }
     $comment = Comment::create(['name' => Input::get('name'), 'email' => Input::get('email'), 'website' => Input::get('website'), 'text' => Input::get('text'), 'post_id' => Input::get('post_id')]);
     if (Input::has('comment_id')) {
         SubComment::create(['comment_id_from' => Input::get('comment_id'), 'comment_id_sub' => $comment->id]);
     }
     return Redirect::back();
 }
Beispiel #2
0
 public function getSubComments()
 {
     $ids = SubComment::where('comment_id_from', '=', $this->id)->orderBy('created_at', 'DESC')->lists('comment_id_sub');
     return Comment::whereIn('id', $ids)->get();
 }