Download the PHP package tapp/filament-auditing without Composer

On this page you can find all versions of the php package tapp/filament-auditing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filament-auditing

Filament Laravel Auditing

Latest Version on Packagist Code Style Action Status Total Downloads

A Filament plugin for Laravel Auditing package. This plugin contains a relation manager for audits that you can add to your Filament resources.

This package provides a Filament resource manager that shows a table with all audits on view and edit pages and allows restore audits.

Version Compatibility

Filament Filament Auditing Documentation
4.x/5.x 4.x Current
3.x 3.x Check the docs
2.x 2.x Check the docs

Installation

[!IMPORTANT] Please check the Filament Auditing plugin version you should use in the Version Compatibility table above.

Note This plugin uses the Laravel Auditing package. First install and configure this package.

You can install the plugin via Composer.

You can publish the view files with:

You can publish the translation files with:

You can publish the config file with:

This is the content of the published config file:

audits_sort: can be used to change the default sort on the audits table.

grouped_table_actions: set to true to group the actions on the audits table.

Multi-Tenancy Support

This plugin supports multi-tenancy for Filament applications. When enabled, all audit records are automatically scoped to the current tenant, ensuring that users only see audits belonging to their tenant.

Configuration

To enable tenancy support, update your config/filament-auditing.php file:

Migration

After enabling tenancy, you need to publish and run the migration to add the tenant column to the audits table.

First, publish the migration:

Then, run the migration:

The migration will automatically add the configured tenant column (e.g., team_id) to the audits table with a foreign key constraint.

Note: The tenant resolver is automatically registered by the plugin's service provider. You do not need to manually add it to your config/audit.php file's resolvers array. The plugin handles this automatically when tenancy is enabled.

How It Works

When tenancy is enabled:

  1. Automatic Tenant Assignment: New audit records are automatically assigned to the current tenant using Laravel Auditing's resolver system. The plugin automatically registers a custom resolver that gets the current tenant from Filament and sets it on new audit records.

  2. Query Scoping: All audit queries are automatically scoped to the current tenant:

    • The AuditResource list page only shows audits for the current tenant
    • The ViewAudit page only allows viewing audits belonging to the current tenant
    • The AuditsRelationManager only shows audits for the current tenant
  3. Security: The restore action validates that the audit belongs to the current tenant before allowing restoration, preventing cross-tenant data access.

Important Notes

Integrate Filament Auditing Tailwind classes

Filament recommends developers create a custom theme to better support plugin's additional Tailwind classes. After you have created your custom theme, add the Filament Auditing vendor path to your theme.css file, usually located in resources/css/filament/admin/theme.css:

Usage

To show the audits table in your Filament resource, just add AuditsRelationManager::class on your resource's getRelations method:

To show the Audit resource in navigation menu, add to your panel provider, e.g. AdminPanelProvider.php:

That's it, you're all set!

If you access your resource, and edit some data, you will now see the audits table on edit and view pages.

Appareance

Relation Manager

Filament Audit Relation Manager

Resource

Filament Audit Resource

View Audit

Filament Audit Resource

Filament Audit Resource

Filament Audit Resource

Restore Action

Filament Audit Resource

Extending Columns

In case you need to add a column to the AuditsRelationManager that does not already exist in the table, you can add it in the config using the format denoted in the example below, and it will be prepended to the table builder. The name of the column to be added is the key of an associative array that contains other information about the class, as shown in the example below. The class instance of the column must be added, but the methods can be left out if not required, or added wherever necessary.

After adding this information in the config, please run this command for changes to take place.

Methods with two or more parameters can be specified with an array like so:

Custom View Data Formatting

If you want to modify the content of the audit to display the old and new values in a specific way, such as showing the value of a specific column instead of the ID for relationships, or even customize the entire view to display data in a different way than the default table, you can use one of these methods described below (first, make sure the plugin views are published):

Show a related column instead of foreign id

To use another field to be displayed for relationships instead of the foreign id, in old and new values, you can add on the mapping array, in filament-auditing.php config file, the label and field that should be displayed, as well as the related model, using the foreign key as the array key. For example, on an user relationship with the user_id foreing key, this config will display the user name along with the User label:

And you'd like to customize the view, you can do it in the published view views/vendor/filament-auditing/tables/columns/key-value.blade.php file.

Customizing the Old and New Values

If you need to customize the presentation for other old and new values, besides the related fields, you can add a formatAuditFieldsForPresentation($field, $record) method on the model that is auditable, with two parameters:

This method must return the formatted audit fields.

For example, let's say you have an Article model that is auditable and contains a related user, and you added a formatAuditFieldsForPresentation($field, $record) method that returns the related user name instead of the id, and the data formatted with some HTML code:

Customizing the Entire View Content

If you'd like to customize the entire view content, you may set the custom_audits_view config value to true on config/filament-auditing.php file:

This modification will allow you to take full control of the display and tailor it to your specific requirements. You can now add your custom content on resources/views/vendor/filament-auditing/tables/custom-audit-content.blade.php file. For example:

The owner record is available to this view via $owner variable. To pass some additional parameters to the view, you may use the custom_view_parameters config:

To format a field, you may also add a formatFieldForPresentation method on the owner model, with the field name and value as parameters, like in the example above. This method must return a formatted field.

For example, in an Article model, to return the name of the related user:

An example of the article.php lang file content used in the custom-audit-content.blade.php view code above:

Permissions

Two permissions are registered by default, allowing access to:

You can override these permissions by adding a policy with audit and restoreAudit.

Event emitted

The auditRestored event is emitted when an audit is restored, so you could register a listener using the $listeners property to execute some extra code after the audit is restored.

E.g.: on Edit page of your resource:

Event listener

The audits relation manager listen to the updateAuditsRelationManager event to refresh the audits table.

So you can dispatch this event in the Edit page of your resource (e.g.: in a edit page of a PostResource -> app/Filament/Resources/PostResource/Pages/EditPost.php) when the form is updated:

[!WARNING] When dispaching this event, set the is_lazy configuration to false, on filament-auditing.php config file, to avoid this exception: "Typed property Filament\Resources\RelationManagers\RelationManager::$table must not be accessed before initialization"


All versions of filament-auditing with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
filament/filament Version ^5.0|^4.0
owen-it/laravel-auditing Version ^14.0||^13.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tapp/filament-auditing contains the following files

Loading the files please wait ...