patrixsmart / adjustfly
Record Laravel model adjustments during updating event.
Requires
- php: ^7.3|^8.0
- laravel/framework: ^8.0|^9.0|^10.0|^11.0
README
Record Laravel model adjustments during updating event.
Installation
Require the patrixsmart/adjustfly
package in your composer.json
and update your dependencies:
composer require patrixsmart/adjustfly
Publish Config files
You will need to publish the config file for you to update it details:
php artisan vendor:publish --tag="adjustfly-config"
Migrate
You will need to migrate the adjustments table exposed by Adjustfly:
php artisan migrate
Adjustfly routes
Adjustfly exposes this routes to your application using the following route.
use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | Adjustment Routes |-------------------------------------------------------------------------- | */ Route::group([ 'namespace' => 'Patrixsmart\Adjustfly\Http\Controllers', 'prefix' => 'api' ], function () { Route::apiResource('adjustments','AdjustmentController')->only(['index','show']); }); /** * http://yourdomain.com/adjustments to get all adjustments with pagination */ /** * http://yourdomain.com/adjustments/{adjustment_id} to see details of an adjustment made with * the current state of the adjustable model. */
Adjustfly Usage
Adjustfly requires you use this trait in any model of your app that you wish to track it adjustments during an updating event.
use Patrixsmart\Adjustfly\Traits\HasAdjustments; class ModelClass extends Model { use HasAdjustments; // This exposes this methods to the model // ModelClass->recordAdjustment() and ModelClass->adjustments() }
and use this trait in your User model tosee adjustments made by a particular user.
use Patrixsmart\Adjustfly\Traits\OwnedAdjustments; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use OwnedAdjustments; // This exposes this method to the model // UserClass->ownedAdjustments() }
Finally call the recordAdjustment method on the model using the HasAdjustments trait in it static updating or observer updating event method.
Adjustfly Sponsors
We would appreciate your sponsorship for the development of Adjustfly. If you are interested in becoming a sponsor, please contact PatriXsmarT LLC. via package@patrixsmart.com.
Contributing
Thank you for considering contributing to the PatriXsmart Adjustfly!.
Security Vulnerabilities
If you discover a security vulnerability within Adjustfly, please send an e-mail to PatriXsmarT LLC. via package@patrixsmart.com. All security vulnerabilities will be promptly addressed.
License
PatriXsmarT Adjustfly is open-sourced software licensed under the MIT license.