Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Termlaravel validation exists array data

//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 :: laravel collection get unique values 
Php :: Termlaravel validation exists array rules 
Php :: contact form 7 checkbox2 
Php :: How to calculate the sum of values in a list PHP 
Php :: Change WordPress Login Logo Url 
Php :: symfony add field to entity 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) laravel 
Php :: while true php 
Php :: php catch echo output 
Php :: clear cache symfony 
Php :: wordpress remove taxonomy from post 
Php :: Laravel eloquent permanent soft delete 
Php :: use php var in js 
Php :: php slice last arrat 
Php :: laravel Impossible to create the root directory 
Php :: laravel except method 
Php :: create array php 
Php :: foreign key cosntraint laravel 
Php :: ci constructor 
Php :: file_get_content 
Php :: contact form 7 get form id 
Php :: Unknown column type "double" requested. Any Doctrine type that you use has to be registered with DoctrineDBALTypesType::addType 
Php :: echo in console command laravel 
Php :: laravel request has 
Php :: laravel create on model 
Php :: Use DateTime() and DateInterval() Objects for PHP 5.3 and Above and Calculate the Difference Between Two Dates Using PHP 
Php :: wp php get rows number from mysql 
Php :: wordpress enable post thumbnail 
Php :: pdo mysqli error handling 
Php :: php array_fill 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =