Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to check exist in array in rule validation laravel

['someProperty' => ['required', Rule::in(['needed', 'stuff'])]];
Comment

laravel validation exists array

//Be careful it does multiple queries.
//'document_group_ids.*' => 'exists:document_groups,id'

public function rules(): array
{
   return [
       'document_type_id' => 'required|integer|exists:document_types,id',
       'document_group_ids' => 'required|array',
       'document_group_ids.*' => 'exists:document_groups,id',
    ];
}
Comment

laravel validation exists array

$request = [
    'ids' => [1, 2, 3, 4],
];

$rules = [
    'ids' => 'required|array',
    'ids.*' => 'exists:users,id', // check each item in the array
];

$validator = Validator::make($request, $rules);

dd($validator->passes(), $validator->messages()->toArray());
Comment

PREVIOUS NEXT
Code Example
Php :: insert timestamps manually in laravel 
Php :: laravel if file is image 
Php :: php parse html 
Php :: new line php 
Php :: default null migration laravel 
Php :: check string php 
Php :: php count array elements with specific key 
Php :: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in 
Php :: laravel get last month records 
Php :: how to reverse fetch assoc in php 
Php :: sha256 php 
Php :: laravel mixed content error 
Php :: php get extension from file from form submit 
Php :: How to insert time in table using CodeIgniter 
Php :: composer 
Php :: laravel get file contents from storage 
Php :: laravel limit query pagination 
Php :: factorial program in php using recursive function 
Php :: php convert special characters to normal 
Php :: php print character x times 
Php :: How To Force Redirect HTTP To HTTPS In Laravel Using htaccess 
Php :: wherein laravel 
Php :: require all files in directory php 
Php :: format date in laravel using carbon 
Php :: laravel group by on subquery 
Php :: pagination prestashop 1.7 
Php :: wp get category by id 
Php :: how to check if there is an authenticated user laravel 
Php :: php open csv 
Php :: laravel seed fresh 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =