laravel-helper maintained by tobymaxham
Description
Bundle of Laravel helper stuff
Author
Last update
2019/12/30 20:07
(dev-master)
License
Downloads
103
TobyMaxham Laravel Helpers
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.