ok,
seems to work just fine after all but just not with seeds.. which makes kinda sense. you'd have to manually call your random data function:
User::find(
DB::table('users')->insertGetId([
'selector' => bin2hex(random_bytes(4)),
...
'created_at' => date("Y-m-d H:i:s")
])
)->assignRole('accountmanager');
beware,
im using random data and this will not work with 'ID' field.
first of all, the ID field needs to be autoincrement for functions like insertGetId() to keep working.
second, you could figure you never use insertGetId or will work around it.
this is possible... but keep in mind that a lot of other packages might make use of the User model and expect to link it to ID filed with a foreign key like: int user_id
this will all break when re-configuring id field from int to text.
you could think you could in this case add this to User model:
protected $primaryKey = 'selector';
but this doesnt change anything... this will still break aforementioned arguments.
my approach is to keep the default ID field and simply add an extra field called 'selector' and use that for referencing/editing users so a edit resource link becomes:
/users/4b35b138/edit instead of /users/2/edit for example.
you need to adapt your update method to handle to selector instead of id:
public function update(Request $request, $locale, $selector) {
//$user = User::findOrFail($id); // no longer works
$user = User::where('selector', $selector)->firstOrFail(); // new way
...
hope this helps others looking for the same solution