laravel make Validator code example
Example 1: image validate in laravel validater
$this->validate($request, ['file' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',]);
Example 2: validate laravel
$validatedData = $request->validate([
'title' => ['required', 'unique:posts', 'max:255'],
'body' => ['required'],
]);
Example 3: validate field for existing client laravel
unique:users,username,id,1 // table, field, idcolumn, value to ignore
Example 4: laravel validation
Rule::unique('users')->ignore($user->id, 'user_id')