Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel request validation rules for create and update

    public function rules()
    {
        $rules = [
            'name' => 'required|string|unique:products|max:255',
        ];

        if (in_array($this->method(), ['PUT', 'PATCH'])) {
            $product = $this->route()->parameter('product');

            $rules['name'] = [
                'required',
                'string',
                'max:255',
                Rule::unique('loan_products')->ignore($product),
            ];
        }

        return $rules;
    }
Comment

PREVIOUS NEXT
Code Example
Php :: faker instance in tinker 
Php :: php check year and month is between two dates 
Php :: vs code php tag shortcut 
Php :: calculate age from date of birth in php 
Php :: eloquent insert 
Php :: delay in php 
Php :: php get filename 
Php :: PHP array_merge() Function 
Php :: laravel invoice toturial 
Php :: laravel has many with ids 
Php :: FPDF invoice Tutorial 
Php :: select2 on modal 
Php :: php curl detect 404 
Php :: download xampp php 7.3 
Php :: create symfony demo app 
Php :: laravel order by before group by 
Php :: random string number generator in php codeigniter 
Php :: laravel mail cc 
Php :: display all files in a directory php 
Php :: php join 
Php :: where like in laravel 
Php :: PHP: How to remove specific element from an array? 
Php :: cron job every 5 minutes wordpress 
Php :: laravel adding condition to relation 
Php :: display name cat product woocommerce 
Php :: clear cache using laravel controller 
Php :: laravel CORS config `allowed_origins` should be an array 
Php :: laravel eloquent relationship 
Php :: run composer with specific php version 
Php :: is legged in wodpress 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =