hypermetrica/nova-auditing-fields

A Laravel Nova field that works with the Laravel Auditing package to see who created or last updated a resource.

dev-master 2021-12-15 07:36 UTC

This package is not auto-updated.

Last update: 2024-04-18 16:37:56 UTC


README

A Laravel Nova field that works with the Laravel Auditing package to see who created or last updated a resource.

Installation

You can install the package in to a Laravel app that uses Laravel Nova and the Laravel Auditing package via composer:

composer require hypermetrica/nova-auditing-fields

Usage

Once installed, you can begin using the CreatedBy and UpdatedBy fields inside a resource.

Please take note that the model of the resource should be using the Auditable trait and implements the Auditable contract as explained in the Laravel Auditing package: http://laravel-auditing.com/docs/8.0/model-setup.

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use OwenIt\Auditing\Contracts\Auditable;

class User extends Model implements Auditable
{
    use \OwenIt\Auditing\Auditable;

    // ...
}

And in your resource:

<?php
use Hypermetrica\NovaAuditingUserFields\CreatedBy;
use Hypermetrica\NovaAuditingUserFields\UpdatedBy;
use Illuminate\Http\Request;

class User extends Resource
{
    // ...
    public function fields(Request $request)
    {
        return [
            // ...
            CreatedBy::make('Created By'),
            UpdatedBy::make('Updated By')->onlyOnDetail(),
            // ...
        ];
    }
}

License

The MIT License (MIT). Please see License File for more information.