1. Go to this page and download the library: Download lara-igniter/activitylog library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Laraigniter\Activitylog\Models\Concerns\LogsActivity;
use Laraigniter\Activitylog\Support\LogOptions;
class Receipt extends Model
{
use LogsActivity;
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults()
->logFillable()
->logOnlyDirty()
->logExcept(['internal_note'])
->dontLogEmptyChanges()
->useLogName('receipts')
->setDescriptionForEvent(static function (string $event): string {
return "Receipt {$event}";
});
}
}
return LogOptions::defaults()
->logFillable()
->logMorphs(['addressable']); // addressable_type and addressable_id
$activities = (new Laraigniter\Activitylog\Models\Activity())
->inLog('receipts')
->forEvent('updated')
->latest()
->all();
(new Laraigniter\Activitylog\Actions\CleanActivityLogAction())->execute();