laravel required if code example

Example 1: laravel exists validation

'state_id' => 'exists:states,id'

Example 2: laravel validation

/**
 * Store a new blog post.
 *
 * @param  Request  $request
 * @return Response
 */
public function store(Request $request)
{
    $validatedData = $request->validate([
        'title' => 'required|unique:posts|max:255',
        'body' => 'required',
    ]);

    // The blog post is valid...
}

Example 3: laravel required if

"sale_price" => "required_if:list_type,==,selling"

Example 4: laravel unique validation

unique:table,column,except,idColumn

############## Example : ################

############### For Updating  
//rules
'email' => 'unique:users,email_address,' . $userId,

############### For Creating 
//rules
'email' => 'unique:users,email_address',

Example 5: required_if laravel

public function rules()
 {
    return [
      'reclamo_procede'  => 'max:1',             
      'solucion_minutos' => 'required_if:reclamo_procede,==,si', 
    ];
 }

Tags:

Misc Example