Download the PHP package bytestgear/laravel-accountable without Composer

On this page you can find all versions of the php package bytestgear/laravel-accountable. 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 laravel-accountable

Accountable Eloquent models

Latest Stable Version CircleCI Travis Build Code Quality StyleCI License

This package provides a trait that tracks the user responsible for creating, modifying, or deleting an Eloquent model.

Accountable will observe any activity on your models and it sets the created_by_user_id, updated_by_user_id, and deleted_by_user_id accordingly using the currently authenticated user.

It also provides you with some useful scope query functions, allowing you to fetch models that were either created, modified, or deleted by a specific user.

Table of Contents

Installation

This package can be installed through Composer:

The package will automatically register itself.

Optionally, publish the configuration file:

The configuration file allows you to set the preferred authentication driver, the database column names, and anonymous user. The latter can be used to deal with records created/updated by unauthenticated users.

When left untouched, Accountable will use the default authentication driver and the default column names (created_by_user_id, updated_by_user_id, and deleted_by_user_id).

Usage

In order to add Accountable to your Laravel application, you'll need to:

  1. Add the required columns to your migration file(s).
  2. Use the trait on your model(s).

Please note that due to the nature of Laravel event system, mass updates will not be handled by Accountable.

Using the Migration helper

The migration helper simplifies the process of adding columns to your migration:

Tip: if you do not use soft-deletes on your model, use Accountable::columns($table, false) to prevent the helper from adding a deleted_by_user_id column.

Using the Trait

Add the Accountable trait on the models you want to track:

Examples

Set up your model and make sure you are authenticated.

Basics

Create a project and show the name of the user that created it:

Get all projects created by a specific user:

Properties

You can use the following properties and methods to reveal the user responsible for creating, updating or deleting the record.

Scope Queries

The following scope queries are at your disposal:

Disable Logging

In some cases, you don't want to automatically save the user along with the model (for example: when seeding test data). You can disable accountable by using the disableUserLogging method.

If you want to re-enable accountable, simply use the enableUserLogging method afterwards.

Impersonation

When authentication is not available - for example, when running jobs in a queue - you might want to "impersonate" a user. Simply override user identification with the actingAs method:

You can end the impersonation by calling the reset method.

Tests

The package contains integration tests. You can run them using PHPUnit.

Changelog

Refer to CHANGELOG for more information.

Contributing

Refer to CONTRIBUTING for contributing details.

Credits

License

The MIT License (MIT). Refer to the License for more information.


All versions of laravel-accountable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^10.0
illuminate/database Version ^10.0
illuminate/config Version ^10.0
illuminate/contracts Version ^10.0
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 bytestgear/laravel-accountable contains the following files

Loading the files please wait ....