Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Termlaravel validation exists array rules

//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 :: php get screen size 
Php :: php passing variables axios 
Php :: How to calculate the sum of values in a list PHP 
Php :: wordpress get plugin list 
Php :: check if date has passed php 
Php :: kartik select 2 yii2 
Php :: cors error angular php 
Php :: php get char from string position 
Php :: sanitize file name 
Php :: php artisanmigrate 
Php :: laravel get route parameters in blade value 
Php :: PHP strtoupper — Make a string uppercase 
Php :: post loop 
Php :: laravel cors enable 
Php :: today date to ago for the date in php 
Php :: how condition for multiple row by orwhere laravel 
Php :: Laravel - Query Builder Left join 
Php :: internal server error phpmyadmin 
Php :: wordpress send reset password link inside wp_new_user_notification_email 
Php :: php check image size before upload 
Php :: drupal 9 guzzle client increase timeout 
Php :: windows logged in user name in php 
Php :: laravel search multiple tables 
Php :: laravel auth 
Php :: laravel validation numeric vs integer 
Php :: echo errors php 
Php :: update query laravel 
Php :: how to deploy laravel windows 
Php :: route() and with() in laravel 
Php :: laravel use config 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =