laravel required if code example
Example 1: laravel exists validation
'state_id' => 'exists:states,id'
Example 2: laravel required if
"sale_price" => "required_if:list_type,==,selling"
Example 3: laravel validation
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
}
Example 4: laravel unique validation
unique:table,column,except,idColumn
'email' => 'unique:users,email_address,' . $userId,
'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',
];
}