Search
 
SCRIPT & CODE EXAMPLE
 

PHP

conditional validation laravel based on role

public function rules()
{
    // Standard rules
    $rules = [
        'field1' => 'required',     
        'field2' => 'required',
    ];

    if (auth()->user()->role === 'admin') {
        $rules['field3'] = 'required';
    }

    return $rules;
}
Comment

PREVIOUS NEXT
Code Example
Php :: wp menu declaration 
Php :: Regullar date format for php 
Php :: array random php 
Php :: laravel migration drop foreign keys 
Php :: cut pice of text in laravel 
Php :: woocommerce recipient email default change Function 
Php :: Uncaught Error: Call to undefined function add_submenu_page() 
Php :: switch case or case php 
Php :: php move in array 
Php :: stampare array php foreach 
Php :: laravel @class 
Php :: php signature capture 
Php :: Edit PHP INI 
Php :: laravel 7 upload file s3 
Php :: using laravel passport with mongodb 
Php :: php division 
Php :: Error : Call to undefined method IlluminateNotificationsChannelsMailChannel::assertSentTo() 
Php :: php is_assoc 
Php :: Create progress bar with Laravel 
Php :: how to re assign value of associative array after assign in php 
Php :: livewire model array 
Php :: laravel How to include model attribute automatically 
Php :: laravel collection find 
Php :: check if the logged in user is admin 
Php :: codeigniter 3 session not working after some time 
Php :: difference between array_merge and + 
Php :: php nested class 
Php :: bool value of blank string inp php 
Php :: php crud generator 
Php :: laravel where json array column 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =