what is validation time laravel controller 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: required_without_all laravel

1. required_with:foo,bar,...
  
Use Case: The field under validation must be present and not empty only if any 
=========  of the other specified fields are present.

2. required_with_all:foo,bar,...
  
Use Case: The field under validation must be present and not empty only if all 
=========   of the other specified fields are present.

3. required_without:foo,bar,...

Use Case: The field under validation must be present and not empty only when 
========  any of the other specified fields are not present.

4. required_without_all:foo,bar,...

Use Case: The field under validation must be present and not empty only when 
=========  all of the other specified fields are not present.