PHP code example of admn / admn-laravel

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

    

admn / admn-laravel example snippets


 

namspace App\Models;

class User extends Authenticatable {
    ...
    use \Admn\Admn\PerformsActions;
    ...
        
    /**
     * How we display the entity in our interface 
     * @return string
     */
    protected function getAuditDisplayValue()
    {
        return $this->name;
    }
    
    /**
    * Key used to identify the entity in our platform 
    * @return string
    */
    protected function getAuditIdentifierKey()
    {
         return 'email';
    }
    
    /**
     * Value used to identify the entity in our platform 
     * @return string|int
     */
    protected function getAuditIdentifierValue()
    {
        return $this->email;
    }
}


    $user = User::find(1);

    $user->logAction('Updated post title',['post:123'],['title' => 'My new title']);

    //OR in PHP 8.0+
    $user->logAction(
        action: 'Updated post title',
        tags: [
            'post:123'
        ],
        context: [
            'title' => 'My new title'
        ]
    );