PHP code example of coderscantina / laravel-transform-requests

1. Go to this page and download the library: Download coderscantina/laravel-transform-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/ */

    

coderscantina / laravel-transform-requests example snippets


 namespace App;
 
use Neon\Request\ApiRequest;
 
class TestApiRequest extends ApiRequest
{

}

 namespace App;
 
use Neon\Request\TransformRequest;
 
class TestTransformRequest extends TransformRequest
{
    protected $transform = [
        'foo_bar' => 'fooBar',
    ];

}



class TestController extends \Illuminate\Routing\Controller
{
    public function a(TestTransformRequest $request)
    {
        $request->get('foo_bar'); // 'baz'
        $request->all(); // -> ['foo_bar' => 'baz']
    }
    
    public function b(TestApiRequest $request)
    {
        $request->get('foo_bar'); // 'baz'
        $request->all(); // -> ['foo_bar' => 'baz']
    }
}