LaravelPackages.net
Acme Inc.
Toggle sidebar
admn/admn-laravel

Laravel Package To Interact With ADMN Service

396
0
1.3.12
About admn/admn-laravel

admn/admn-laravel is a Laravel package for laravel package to interact with admn service. It currently has 0 GitHub stars and 396 downloads on Packagist (latest version 1.3.12). Install it with composer require admn/admn-laravel. Discover more Laravel packages by admn or browse all Laravel packages to compare alternatives.

Last updated

ADMN.io Laravel SDK

A simple wrapper for ADMN.io API written in PHP for Laravel.

Features

  • Log action as entity (User, Customer, Employee, etc. Any Model you apply our Trait to)

Requirements

  • PHP 7+
  • ADMN PHP SDK (automatically installed via Composer dependency)

Installation

Via Composer.

composer require admn/admn-laravel

php artisan vendor:publish --provider="Admn\Admn\AdmnServiceProvider"

Model Configuration

<?php 

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;
    }
}

Usage

    $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'
        ]
    );

Coming Soon

  • [ ] Ability to retrieve actions from the API for an actor
  • [ ] Ability to offload action recording to queue
  • [ ] Ability to select a region (as more regions become available)
Comments