Devise\Pages\Fields\FieldsResponseHandler::requestUpdate PHP Method

requestUpdate() public method

Update field, creates a new version of the field this returns json
public requestUpdate ( integer $fieldId, array $input ) : json
$fieldId integer
$input array
return json
    public function requestUpdate($fieldId, $input)
    {
        try {
            $code = 200;
            $response = $this->Manager->updateField($fieldId, $input);
        } catch (ValidationException $e) {
            $code = 403;
            $response = ['message' => $e->getMessage(), 'errors' => $e->getErrors()];
        }
        return Response::json($response, $code);
    }

Usage Example

 public function test_it_handles_update_requests()
 {
     $FieldManager = m::mock('Devise\\Pages\\Fields\\FieldManager');
     $FieldManager->shouldReceive('updateField')->times(1)->andReturn([]);
     $FieldsResponseHandler = new FieldsResponseHandler($FieldManager);
     $FieldsResponseHandler->requestUpdate(1, []);
 }