I am working with a somewhat challenging database structure which I am not yet in a position to update for my client. My problem is as follows:
- The user table has both a id and a pilot_id column. The pilot_id column uses a ABC1234 structure. This is what is currently used as a foriegn key to relate to other tables.
- I have updated my Laravel User.php model to include the following:
protected $primaryKey = 'pilot_id';
protected $keyType = 'string';
public $incrementing = false;
I added the above after encountering issues using Laravel Nova. When adding say a 'post' that belongs to a user, naturally Nova was inserting the users database record id on the relationships 'pilot_id' field which of course didn't match up with anything. The above code fixed that issue.
The issue I am now encountering is that when any action is performed on a record via Nova for some reason Nova is not capturing the authenticated users id / pilot_id and saving it against the action on the action_events table whereas it did previously prior to making the above code changes.
Attached an image of the action_events table showing user_id as 0
Screenshot of Laravel Nova's action panel showing 'Nova User' instead of a users name
I have noticed that this is the same on Laravel's session database table too. Am I unable to use sessions with a custom primary key? Does Nova leverage sessions to record actions?
Any advice appreciated.