Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel custom validation rules

php artisan make:rule Uppercase
Comment

Laravel Rules

public function store(Request $request) {
    $this->validate($request, [
        'name' => 'required|string',
        'body' => 'required|string',
        'publish_at' => 'required|date_format:Y-m-d H:i:s'
    ], [
      'name.required' => 'A article name is required',
      'body.required'  => 'A article body is required',
      'publish_at.date_format' => 'The publish at date is not in the correct format.'
    ]);
 
    // The request validated and this code will get run
    ...
}
Comment

Laravel Rules

public function store(Request $request) {
    $this->validate($request, [
        'name' => 'required|string',
        'body' => 'required|string',
        'publish_at' => 'required|date_format:Y-m-d H:i:s'
    ], [
      'name.required' => 'A article name is required',
      'body.required'  => 'A article body is required',
      'publish_at.date_format' => 'The publish at date is not in the correct format.'
    ]);
 
    // The request validated and this code will get run
    ...
}
Comment

PREVIOUS NEXT
Code Example
Php :: Code for finding Prime Numbers 
Php :: extract in php useful 
Php :: laravel login and registration with command 
Php :: laravel default rate limit 
Php :: run laravel without php artisan serve 
Php :: laravel send data with a redirect 
Php :: Undefined index: name laravel 
Php :: php-oop 
Php :: laravel route not found 
Php :: route group laravel 8 
Php :: flash message laravel for incorrect password 
Php :: laravel scheduler every 10 minutes 
Php :: add class to li 
Php :: seguridad de las api en laravel 
Php :: woocommerce coupon notifie a spefic email 
Php :: Wordpress even odd post count 
Php :: remove dashboard mya ccount 
Php :: php get sql update from session 
Php :: laravel 7 factory tinker 
Php :: ob_start store variable in php 
Php :: short isset and not empty php 8 
Php :: enhanced ecommerce data layer for woocommerce 
Php :: direct without public laravel 
Php :: shorthand to assign multiple variable to same value in php 
Php :: display rounded price get_price php 
Php :: laravel eager loading pass variable in withCount where condition 
Php :: print average result in php 
Php :: laravel validate form data unique array 
Php :: app/View/Errors/missing_controller.ctp 
Php :: view codeigniter 4 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =