Skip to content

Instantly share code, notes, and snippets.

@thiagoeliasr
Last active June 25, 2019 14:25
Show Gist options
  • Save thiagoeliasr/81edc3ea0063a4863e721282e223f734 to your computer and use it in GitHub Desktop.
Save thiagoeliasr/81edc3ea0063a4863e721282e223f734 to your computer and use it in GitHub Desktop.
Validate normal or JSON raw requests in Laravel FormRequest
<?php
class ApiRequest extends FormRequest
{
protected function validationData()
{
return count($this->json()->all()) ? $this->json()->all() : $this->all();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment