PHP code example of hosseinesteki / activity_log

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

    

hosseinesteki / activity_log example snippets


use ActivityLog\Traits\HasActivityLog;

class Post extends Model
{
    use HasActivityLog;

    protected $fillable = ['title', 'content'];
}

use ActivityLog;

ActivityLog::log([
    'user_id' => auth()->id(),
    'model'   => 'App\Models\Post',
    'action'  => 'update',
    'model_id'=> 12,
    'changes' => ['title' => ['old' => 'A', 'new' => 'B']],
]);

$logs = ActivityLog::all([
    'user_id' => 1,
    'action'  => 'update',
    'date_from' => '2026-02-01',
    'date_to'   => '2026-02-05',
]);

$results = ActivityLog::search('Post', [
    'user_id' => 2,
]);

$stats = ActivityLog::stats();
bash
php artisan vendor:publish --provider="Vendor\ActivityLog\ActivityLogServiceProvider" --tag=migrations
php artisan migrate

GET /api/activity-log?user_id=1&action=update&date_from=2026-02-01&date_to=2026-02-05