Hi all,
How to get the primary key field name of model? The document said the primaryKey() method ‘The default implementation simply returns null, meaning using the primary key defined in the database.’ if not overridden.
Does the following code work?
$attributeNames = $model->attributeNames();
$pkFieldName = $attributeNames[0];
Thanks.