How to validate a database column on uniqueness in Laravel
Categorized as Laravel
You can see if the column in your Laravel application DB is unique or not. For example, the article table has slug and author_id with the unique slug for each author. See the code below, it’s useful for multi-tenancy:
public function rules()
{
return[
'slug' => [
Rule::unique('articles')->where('author_id', Auth:id())
],
];
}