signifly / laravel-manageable
Track users who manages models in your Laravel app
Installs: 7 215
Dependents: 0
Suggesters: 0
Security: 0
Stars: 41
Watchers: 6
Forks: 5
Open Issues: 0
Requires
- php: ^7.4|^8.0
- illuminate/database: ^8.0|^9.0|^10.0
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0
README
The signifly/laravel-manageable
package allows you to easily track who creates/updates your models.
All you have to do to get started is:
// 1. Add required columns to your table by using our macro manageable Schema::create('orders', function (Blueprint $table) { // ... $table->manageable(); // params: $bigIntegers (default: true), $foreignTable (default: 'users'), $foreignKey (default: 'id') $table->manageable(false, 'some_users_table', 'u_id'); }); // 2. Add the Manageable trait to your model class Order extends Model { use Manageable; }
The macro manageable
adds the following to your table:
$this->unsignedBigInteger('created_by')->nullable()->index(); $this->unsignedBigInteger('updated_by')->nullable()->index(); $this->foreign('created_by') ->references('id') ->on('users') ->onDelete('set null'); $this->foreign('updated_by') ->references('id') ->on('users') ->onDelete('set null');
Documentation
Until further documentation is provided, please have a look at the tests.
Installation
You can install the package via composer:
composer require signifly/laravel-manageable
The package will automatically register itself.
You can publish the config with:
php artisan vendor:publish --provider="Signifly\Manageable\ManageableServiceProvider"
Testing
composer test
Security
If you discover any security issues, please email dev@signifly.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.