PHP code example of aginev / activity-log

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

    

aginev / activity-log example snippets


// config/app.php

'providers' => [
    '...',
    Aginev\ActivityLog\ActivityLogServiceProvider::class,
];

// app/Console/Kernel.php

protected $commands = [
    '...',
    \Aginev\ActivityLog\Commands\ActivityLogClean::class,
];

use \Aginev\ActivityLog\Traits\ObservableModel;

/**
 * Implement this method to set custom activity description message
 * @param $event Event name
 * @param User $user Current logged in user
 * @return string
 */
public function activityDescription($event, User $user = null) {
    return 'User ' . $this->full_name . ' has been ' . $event . ' from ' . $user->full_name;
}

$logs = \ActivityLog::getActivities()->get(); // Get all activities
$logs = \ActivityLog::getLatestActivities(2); // Get latest 2 activities

$logs = \ActivityLog::cleanLog(30); // Offset in days
sh
php artisan vendor:publish --provider="Aginev\ActivityLog\ActivityLogServiceProvider" --tag="migrations"
php artisan migrate
sh
php artisan vendor:publish --provider="Aginev\ActivityLog\ActivityLogServiceProvider" --tag="config"
sh
php artisan activity-log:clean