dphphvs496524 2019-04-06 14:32
浏览 44

自定义Eloquent主键,会话和Laravel Nova

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算