PHP code example of elkady / activity-logger

1. Go to this page and download the library: Download elkady/activity-logger 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/ */

    

elkady / activity-logger example snippets


use Elkady\ActivityLogger\Traits\HasActivityLogs;

class Post extends Model
{
    use HasActivityLogs;
}

$post->activityLogs; // logs recorded about this Post

use Elkady\ActivityLogger\Models\ActivityLog;

// everything that happened to a given Post
ActivityLog::forSubject($post)->get();

// everything a given user did
ActivityLog::causedBy($user)->get();

// combine, filter by action, filter by date range, paginate
ActivityLog::forSubject($post)
    ->causedBy($user)
    ->ofAction(['updated', 'deleted'])
    ->between('2026-01-01', '2026-07-22')
    ->latest()
    ->paginate(25);

// filter by type only, without a specific instance
ActivityLog::forSubject(Post::class)->ofAction('deleted')->get();

'ui' => [
    'enabled' => true,
    'path' => 'activity-logs',
    'middleware' => ['web', 'auth'], // add your own auth middleware here
],

return [
    'guards' => ['web', 'api'],

    'log_actions' => ['created', 'updated', 'deleted', 'restored'],
];
bash
php artisan vendor:publish --provider="Elkady\ActivityLogger\ActivityLoggerServiceProvider" --tag=config
arduino
config/activity-logger.php
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Elkady\ActivityLogger\ActivityLoggerServiceProvider" --tag=views