public function add() { if (!Input::has('comment')) { return Response::json(array('statusCode' => 202, 'error' => 'invalid param(s).')); } $comment = new Comment(); $comment->text = Input::get('comment'); $comment->created_at = (new DateTime())->format('Y-m-d H:i:s'); $service = new CommentService($comment); if ($service->save()) { return Response::json(array('statusCode' => 200, 'message' => 'success')); } return Response::json(array('statusCode' => 202, 'error' => 'database error occur.')); }