laravel rule in code example
Example 1: laravel unique validation
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
}
Example 2: create form request laravel
php artisan make:request StoreBlogPost
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: laravel validation
Rule::unique('users')->ignore($user)