Posts

Showing posts with the label polymorphic-associations

Polymorphic Laravel Auditing Package - Retrieving polymorphic audits

Polymorphic Laravel Auditing Package - Retrieving polymorphic audits I am currently using Laravel Auditing (Owen-it) package to audit models automatically which is working great using the following code. class Staff extends Model implements Auditable { use OwenItAuditingAuditable; use SoftDeletes; } class Customer extends Model implements Auditable { use OwenItAuditingAuditable; use SoftDeletes; } Seeing as there is a significant number of fields (> 20) on these classes I am intending to convert these classes to a polymorphic relationship where all common fields reside in the base class and any class unique properties will go in their respective classes. For example - the base class: class User extends Model implements Auditable { use OwenItAuditingAuditable; use SoftDeletes; } Currently I use something like this to retrieve audits: $staff = AppModelStaff::find($id); $allAudits= $staff->audits; My question is then is there a clean way to retrieve all audits acro...