robwilkerson / CakePHP-Audit-Log-Plugin

Records changes made to an object during CRUD operations.
104 stars 78 forks source link

Unable to add audit log #115

Closed dhavalorafox closed 7 years ago

dhavalorafox commented 7 years ago

Hi,

I am using robwilkerson/CakePHP-Audit-Log-Plugin for add audit log. I have successfully setup plugin in my project. But when i tried to update any record at that time it gives me below error.

Error: Call to a member function create() on null File: D:\wamp64\www\auditlogproject\app\Plugin\AuditLog\Model\Behavior\AuditableBehavior.php

So please can any one guide me which thing i forgot in call auditable behavior.

dhavalorafox commented 7 years ago

I fixed this issue with change runtime association with the Audit model under aftersave method in AuditableBehavior.php.

// Create a runtime association with the Audit model $Model->bindModel( array('hasMany' => array('Audit')) // changed AuditLog.Audit to Audit ); $Model->Audit->bindModel( // had to bind AuditDelta to Audit array( 'hasMany' => array( 'AuditDelta' ) ) );

Thanks you.