Home > Software engineering >  A certain record is always being pointed to for validation
A certain record is always being pointed to for validation

Time:01-28

I have a problem: there is a specific record that is always triggering the exists check, I don't know why exactly, I can't make my request because that doctor is not being found.

This doctor is also in the doctors table by storing his name in name of that table, the funny thing is that when I look for this record in phpMyAdmin by the cpf field that is in both tables, it is possible to find this record, I don't know how to solve this, does anyone know how to help me? If it is a problem of consistency of data.

The field name and cpf of table users and doctor are in nullable(), this contributes in some way for the error?

    public function rules()
    {
        return [
            'doctor_attendant' => 'required|exists:users,name',
        ];
    }

CodePudding user response:

Try the changing the validation rule to the following:

'doctor_attendant' => 'required|exists:doctors,cpf',

CodePudding user response:

I hope this helps you if you want to check data already exists then you can use below. Tested one

'doctor_attendant' => 'required|unique:table_name,field_name',
  • Related