diff --git a/src/Controllers/Traits/Api.php b/src/Controllers/Traits/Api.php index 6581194..9649001 100644 --- a/src/Controllers/Traits/Api.php +++ b/src/Controllers/Traits/Api.php @@ -32,10 +32,11 @@ abstract protected function model(); /** * Should return the validation rules * + * @param array $data The data being validated * @param boolean $forUpdate Indicates whether the validation should be for update or not * @return array */ - abstract protected function validationRules($forUpdate = false); + abstract protected function validationRules(array $data, $forUpdate = false); /** * Indicates whether validation should be strict and throw errors if unwanted @@ -251,7 +252,7 @@ public function index() public function store(Request $request) { $data = $request->all(); - if ($resp = $this->checkRequestData($data, $this->validationRules())) + if ($resp = $this->checkRequestData($data, $this->validationRules($data))) return $resp; $model = $this->storeModel(); @@ -296,7 +297,7 @@ public function show($id) public function update(Request $request, $id) { $data = $request->all(); - if ($resp = $this->checkRequestData($data, $this->validationRules(true))) + if ($resp = $this->checkRequestData($data, $this->validationRules($data, true))) return $resp; $model = $this->updateModel(); diff --git a/src/Helpers/Http.php b/src/Helpers/Http.php index 20afa30..e5eb764 100644 --- a/src/Helpers/Http.php +++ b/src/Helpers/Http.php @@ -20,7 +20,7 @@ private static function client() private static function processResponse() { - return json_decode(strval(self::$response->getBody())); + return json_decode(strval(self::$response->getBody()), true); } private static function req($method, array $args)