How to properly use composite keys as the primary key in Laravel with Spatie Roles and Permissions package?

I need to use both email and phone_number as the primary key for the User model in my Laravel application. Since Laravel doesn’t natively support composite primary keys, I found a workaround to implement it. However, I’m facing issues with relationships, especially when using the Spatie Roles and Permissions package. Specifically, I’m getting an “Array to string conversion” error. Also facing issue on auth()->user() helper function which is returning unexpected result.

Here’s the setup I have:

User Model:

namespace AppModels;

use IlluminateFoundationAuthUser as Authenticatable;
use SpatiePermissionTraitsHasRoles;
use IlluminateDatabaseEloquentBuilder;

class User extends Authenticatable
{
    use HasRoles;

    public $incrementing = false;
    protected $keyType = 'string';
    protected $primaryKey = ['email', 'phone_number'];
    
    protected $fillable = ['email', 'phone_number', 'name', 'password'];
}

Issue:
When accessing relationships like $user->roles, I encounter the following error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'where clause' (SQL: select * from `users` where (`0` = email and `1` = phone_number) and `users`.`deleted_at` is null limit 1)