search

Home  >  Q&A  >  body text

How to filter soft deleted data in laravel's unique verification

It is a field unique verification, in addition to itself, there are soft deleted records

阿神阿神2843 days ago737

reply all(1)I'll reply

  • 某草草

    某草草2017-05-16 16:50:14

    Use the following method

    'email' => Rule::unique('users')->where(function ($query) {
        $query->whereNotNull('deleted_at')->whereNot('id', 4);
    })
    

    Refer to the official documentation https://laravel.com/docs/5.4/...

    reply
    0
  • Cancelreply