laravel required with out code example
Example 1: laravel validation
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
}
Example 2: laravel validation
use Illuminate\Validation\Rule;
Validator::make($data, [
'email' => [
'required',
Rule::unique('users')->ignore($user->id),
],
]);
Example 3: 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.