Could not log model events for Models without id field #809
Unanswered
sishirrijal
asked this question in
Q&A
Replies: 1 comment 3 replies
-
Hey, the requirement isn't an protected $primaryKey = 'table_first_id';
protected $keyType = 'int';
public $incrementing = false; In general I can only recommend to have a dedicated PK (in best case AI) because it makes a lot of things a lot easier. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am facing a serious issue after including and implementing this package and I am not sure how is this happening.
Environment
PHP Version: 7.2.19
Laravel Version: 5.8.29
Package Version: 3.9.1
Scenario
I have table_first with its model TableFirst with some attributes say: ['id', 't1_first_col', 't1_second_col'].
I have implemented model event logging mechanism in following way.
I also have table_second with a model TableSecond with some attributes: ['table_first_id', 't2_first_col', 't2_second_col']
Model for this table_second is set same as that of first with its corresponding attributes.
i.e.
This second table is created for storing some data that might be supplementary for first one so I haven't put an id field in this table.
Expected Behaviour
When I try to insert data to
TableFirst
&TableSecond
using model from my respective controllers it should work fine and should create a log instance in database.Actual Behaviour
It inserts the data into
table_first
table i.e.TableFirst
model instance is created and also logs the fillable attributes of same.However, for
TableSecond
neither it creates the instance nor logs the fillable attributes, rather, it throws following sort of error.I am damn sure that, It is not working on the models without id attributes as this is happening in every tables with same scenario on my project
Kindly help me figure this issue.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions