PHP code example of nickfla1 / laravel-validated-api-requests

1. Go to this page and download the library: Download nickfla1/laravel-validated-api-requests library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nickfla1 / laravel-validated-api-requests example snippets


use Nickfla1\Utilities\ApiRequest;

class FooRequest extends ApiRequest
{
    /**
     * Defines if the request should fire an ApiRequestException
     * on validation failure.
     *
     * @var bool
     */
    protected $firesException = true;
    
    /**
     * Define validation rules.
     *
     * @return array|null
     */
    protected function rules()
    {
        return [
            'foo' => '

class TheController extends Controller
{
    public function index(FooRequest $request)
    {
        // If we get here the request was validated successfully!
    }
}