PHP code example of shureban / laravel-easy-request

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

    

shureban / laravel-easy-request example snippets


Shureban\LaravelEasyRequest\EasyRequestServiceProvider::class,

/**
 * @method string name()
 * @method boolean isConfirmed()
 * @method bool isAdult()
 * @method integer age()
 * @method int size()
 * @method float salary()
 * @method array workingDays()
 * @method mixed description()
 * @method additionalInformation()
 * @method string|null managerName()
 * @method DateTime birthday()
 * @method Carbon firstWorkingDay()
 */
class CustomRequest extends \Illuminate\Foundation\Http\FormRequest
{
}

class RegistrationController extends Controller
{
    public function __invoke(CustomRequest $request): JsonResponse
    {
        dd(
            $request->name(), // return value with string type
            $request->isConfirmed(), // return value with bool type
            $request->isAdult(), // return value with bool type
            $request->age(), // return value with integer type
            $request->size(), // return value with integer type
            $request->salary(), // return value with float type
            $request->workingDays(), // return array value
            $request->description(), // return original value
            $request->additionalInformation(), // return original value
            $request->managerName(), // return string value or NULL
            $request->birthday(), // return date with type DateTime
            $request->firstWorkingDay(), // return date as Carbon type
        );    
    }
}

/**
 * @method int userId()
 * @method int client_id()
 */
class CustomRequest extends \Illuminate\Foundation\Http\FormRequest
{
    public function rules(): array
    {
        return [
            'user_id' => [' $request->userId(), // return value for field user_id
            $request->client_id(), // return value for field clientId
        );    
    }
}

/**
 * @method User user()
 */
class CustomRequest extends \Illuminate\Foundation\Http\FormRequest
{
    public function rules(): array
    {
        return [
            'user_id' => ['// return instance of models User
        );    
    }
}
shell
php artisan vendor:publish --provider="Shureban\LaravelEasyRequest\EasyRequestServiceProvider"