List all records without ruleschecker

I’m using CakePHP 4 and using bake function. When I save the record from table contacts without user_id it will save the record but not listed in the index. However, if I save contacts record with user_id, it will display the record in the index. I believe it is caused by the paginate->contain in contacts controller. However, when I removed the code, it will produce an error.

    public function index()
{
    $this->paginate = [
        'contain' => ['Users'],
    ];
    $contacts = $this->paginate($this->Contacts);
    $this->set(compact('contacts'));
}

I tried to remove this code from the model, and it also produces an error

public function buildRules(RulesChecker $rules): RulesChecker
{
    $rules->add($rules->existsIn(['user_id'], 'Users'));

    return $rules;
}

How can I list all the record with or without user_id in contacts index? Thank you.

Check out the initialize method in your model. My guess is that the association is set up to do a INNER JOIN strategy, and thats why rows without user_id are not shown.

You can see the SQL queries in debug_kit sql panel to confirm