PHP code example of webtoolsnz / laravel-json-schema-request

1. Go to this page and download the library: Download webtoolsnz/laravel-json-schema-request 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/ */

    

webtoolsnz / laravel-json-schema-request example snippets




namespace App\Http\Requests;

use Webtools\JsonSchemaRequest\JsonSchemaRequest;

class MyJsonRequest extends JsonSchemaRequest
{
    public function schema(): array
    {
        return [
            'type' => 'object',
            'properties' => [
                'first_name' => ['type' => 'string'],
                'last_name' => ['type' => 'string'],
                'email' => ['type' => 'string', 'format' => 'email'],
            ],
            '

public function store(MyJsonRequest $request)
{
    // The incoming request is valid...

    // Retrieve the validated input data...
    $validated = $request->validated();
}