2017 © Pedro Peláez
 

library authority

image

slovenian-gooner/authority

  • Thursday, March 27, 2014
  • by slovenianGooner
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel Authority

A Laravel package that enables automatic appending of authors to a table (also supports Sentry)., (*1)

Warning

This package is still in beta testing, so bugs are expected, they always will be. If you find anything, just post an issue. If you have some ideas on how to upgrade it, feel free to post an issue aswell., (*2)

The trait currently works only if no other trait that overwrites the boot() method is included. Still working on that issue., (*3)

Compatibility

  • Laravel 4.0
  • Laravel 4.1

Installation

Add the package to your composer.json file..., (*4)

"require": {
    "slovenian-gooner/authority": "dev-master"
}

...and then run composer update and that should do it., (*5)

Usage

Include the Authority trait (example on Project model)

Adding the Authority trait will set a saving listener to the Eloquent model., (*6)

class Project extends Eloquent
{
    use SlovenianGooner\Authority\AuthorityTrait;
}

That is all you need to do for the package to work., (*7)

Columns

You need to set the apropriate table columns for the package to work. These are the defaults (example with migration):, (*8)

$table->integer('created_by');
$table->integer('updated_by');

You can customize the columns by adding a protected $authorFields array to your Eloquent model with creating and updating keys like so:, (*9)

class Project extends Eloquent
{
    use SlovenianGooner\Authority\AuthorityTrait;

    protected $authorFields = [
        'creating' => 'custom_column_name_here' // defaults to 'created_by'
        'updating' => 'custom_column_name_here' // defaults to 'updated_by'
    ];  
}

Auth drivers

The package currently supports the integrated Auth driver and the Sentry driver. The default is the Auth driver, but you can change to Sentry by adding a $authDriver property to your Eloquent model like so:, (*10)

class Project extends Eloquent
{
    use SlovenianGooner\Authority\AuthorityTrait;

    protected $authDriver = 'sentry'; // defaults to 'default'
}

Retrieving the authors

You can retrieve the author object by calling one of two methods on your Eloquent model (createdBy or updatedBy)., (*11)

$project = Project::find($id);
dd($project->createdBy());

TODO

  • Extend the Schema Blueprint class to enable automatic appending of the 'author' columns in your migrations.
  • Enable compliance with other traits overwriting the boot() method aswell

The Versions

27/03 2014

dev-master

9999999-dev

  Sources   Download

The Requires

  • php >=5.3.0

 

by Lovro Papež