how to use in case in validate in larave? code example
Example 1: valdidate laravel if falid
$validator = Validator::make($request->all(), [
'name' => 'required|min:2|max:255'
]);
if ($validator->fails()) {
return view('view_name');
} else {
return view('view_name');
}
Example 2: validate field for existing client laravel
unique:users,username,id,1 // table, field, idcolumn, value to ignore