Laravel - Login Fail after adding mutator on User id

79 Views Asked by At

I have classic user id table where the primary key is BigIncrement.

I need to hide the id value from user. So my idea is to use hashIds packages. What I've done to mask the id is by creating mutator on id column:

public function getIdAttribute($id)
{ 
    return Hashids::connection(User::class)->encode($id);
}

The masking working good, but problem happens when I try to login. Seems the login session is not created.

My questions are:

  1. Why the login is failed after creating id mutator? I assume that to create session it involve the id value
  2. Any better way to mask the id, besides using mutator?
0

There are 0 best solutions below