PHP code example of lara-igniter / activitylog

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/ */

    

lara-igniter / activitylog example snippets


Laraigniter\Activitylog\ActivitylogServiceProvider::class,

activity('payments')
    ->event('paid')
    ->performedOn($receiptModel, $receiptId)
    ->withProperty('amount', $amount)
    ->log('Receipt paid');

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();
powershell
php artisan vendor:publish --tag=activitylog-migrations
powershell
php artisan migrate
powershell
php artisan vendor:publish --tag=activitylog-config
powershell
php artisan activitylog:clean
powershell
php artisan activitylog:clean --days=90
php artisan activitylog:clean receipts --days=90
powershell
php artisan activitylog:clean --all
php artisan activitylog:clean receipts --all