Download the PHP package axn/laravel-eloquent-authorable without Composer

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

Laravel Eloquent Authorable

As Laravel Eloquent is able to automatically fill in the created_at andupdated_at fields, this package provides automatic support for the created_by andupdated_by fields in your Eloquent models.

This package will avoid you to always indicate when creating and/or updating a model who is the user who performed this action. This package does it for you and it simplifies the recovery of this information.

So you can easily store and display this kind of information:

Added by AXN on 2016-03-24 and updated by forxer on 2020-10-01

Installation

With Composer :

Usage

To add functionality to a model, it is necessary that:

  1. The related table has the concerned fields (by default created_at and updated_at)
  2. The model use the trait Axn\EloquentAuthorable\Authorable

Database columns

You must create the columns in the database on the table of the model concerned. These columns are used to create the relationship between the related table and the "users" table.

For example :

Migrations helpers

Convenient utilities are available for adding or removing these columns in your migrations:

By default the addAuthorableColumns() method will generate unsignedBigInteger columns type, if you need unsignedInteger instead you can pass the first parameter to false.

Also you can pass a users model class name as third parameter if needed.

Warning ! These utilities use the columns names specified in the package configuration file at the time the migrations are run. If you modify this configuration, before or after having migrated, or if you overload it with the configuration by model, you should not use these utilities but add the columns by yourself. So these utilities are perfects for new application, but for old ones or for existing models, it is also recommended to create the columns yourself.

Important note You can customize both the column names and the users table through settings; and this globally or by model (see below)

Eloquent Model

From now on, each creation/update of an entry in the Posts table the created_by and updated_by columns will automatically be filled with the id of the currently authenticated user.

In addition two 1-n inverse relationships (belongs to) with the users table are available:

Using Eloquent eager-loading

Using in Blade view

Settings

There are two ways to set this feature:

Global configuration

First initialise the config file in your application by running this command:

Then, when published, the config/eloquent-authorable.php config file will contain the default values that you can then customize.

Default values in this file are:

Settings by model

Model and guard

By default, the user model App\User::class and web guard are used.

You can specify different ones like this:

Column names

By default, the created_by andupdated_by columns are used.

You can specify different column names for a model like this:

Enabling/Disabling

You can disable the feature like this:

Full example of custom implementation


All versions of laravel-eloquent-authorable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
illuminate/support Version ^8.0 || ^9.0 || ^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 axn/laravel-eloquent-authorable contains the following files

Loading the files please wait ....