PHP code example of mohit-hasan / laravel-activity-logger

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

    

mohit-hasan / laravel-activity-logger example snippets


use MohitHasan\ActivityLogger\Traits\LogsActivity;

class Post extends Model
{
    use LogsActivity;
}

use MohitHasan\ActivityLogger\Facades\ActivityLogger;

ActivityLogger::action('user_login')
    ->description('User logged in.')
    ->log();

ActivityLogger::action('order_placed')
    ->description('Order placed.')
    ->with(['order_id' => 12345, 'total' => 99.99])
    ->log();

ActivityLogger::action('post_published')
    ->on($post)
    ->log();

$logs = ActivityLogger::getAll();                   // all
$logs = ActivityLogger::getAll(action: 'created');  // filtered
$logs = ActivityLogger::getAll(for: $post);         // for a model

$log = ActivityLogger::action('export')
    ->description('User exported report')
    ->on($report)
    ->with(['format' => 'PDF', 'rows' => 500])
    ->by($userId)
    ->log();
bash
git clone https://github.com/mohit-hasan/laravel-activity-logger.git
cd laravel-activity-logger/demo
cp .env.example .env
composer install
php artisan key:generate
php artisan migrate --seed
php artisan serve