Skip to content

Commit

Permalink
Updated Api and Http
Browse files Browse the repository at this point in the history
  • Loading branch information
ezra-obiwale committed Oct 19, 2017
1 parent a767a2c commit 8d0f8f9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Controllers/Traits/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Helpers/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8d0f8f9

Please sign in to comment.