「Laravel入門」exists()とunique()を利用するサンプル

1.exists()

'email' => [
 'required',
 Rule::exists('staff')->where(function ($query) {
 $query->where('account_id', 1);
 }),
],

2.unique()

'email' => [
 'required',
 Rule::unique('users')->ignore($user->id)->where(function ($query) {
 $query->where('account_id', 1);
 })
],

JavaScript

Posted by arkgame