tobymaxham / laravel-helper
Bundle of Laravel helper stuff
v1.4
2019-12-30 19:07 UTC
Requires
- ext-json: *
- illuminate/http: >=5.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.13
- orchestra/testbench: ~3.5.0|~3.6.0
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^6.1|^7.0
README
Installation
You can install this package via composer:
composer require tobymaxham/laravel-helper
Model Logging
Track User changes
Track if user created, updated or deleted a Model
. You have to add these attributes to you database table.
By default the fields created_by
, updated_by
and deleted_by
fields will be used.
namespace App; use TobyMaxham\Helper\Models\Logs\ChangeByUser; use Illuminate\Database\Eloquent\Model; class User extends Model { use ChangeByUser; }
You could also turn off tracking by returning false
to the attribute fetching methods:
public function getCreatedByColumn() { return false; }
Migration
With my MigrationHelper
you can automatically add the fields to you migrations file:
/** * Run the migrations. * * @return void */ public function up() { Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->text('content'); MigrationHelper::addCreatedByUser($table); $table->timestamps(); }); }
Or you can create all three fields at once by calling MigrationHelper::addChangedByUserFields($table)
.
Changelog
Please see CHANGELOG for more information what has changed recently.
License
The MIT License (MIT). Please see License File for more information.