Form Request Nestead Array In Laravel
I am using Laravel and I have a sorting system and I want to use form request to validate it
so the request is this
array:5 [▼ "type" => "product" "minprice" => "10" "maxprice" => "10000000000" "color" => null "sortBy" => array:2 [▼ "field" => "created_at" "orderBy" => "desc" ] ]
and I want to check 'field' and 'orderBy' to only have for example created_at value and desc value
How can I do this?
here is my form reqeust
return [ 'type' => 'required|in:all,file,service,product', 'minprice' => 'required|numeric|min:0|max:1000000000000', 'maxprice' => 'required|numeric|min:0|max:100000000000000', 'color' => 'min:0|max:7', // 'sortBy' => 'in:desc,orderBy', ];
Read the docs at: https://laravel.com/docs/6.x/validation
If your HTTP request contains "nested" parameters, you may specify them in your validation rules using "dot" syntax:
So you can use:
'sortBy.field' => 'in:created_at,updated_at,deleted_at', 'sortBy.orderBy' => 'in:asc,desc',
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?