patrixsmart/adjustfly

记录Laravel模型在更新事件中的调整。

v1.1 2024-03-24 11:24 UTC

This package is auto-updated.

Last update: 2024-09-24 12:31:08 UTC


README

记录Laravel模型在更新事件中的调整。

安装

在您的composer.json中要求patrixsmart/adjustfly包并更新您的依赖项

composer require patrixsmart/adjustfly

发布配置文件

您需要发布配置文件以便更新其详细信息

php artisan vendor:publish --tag="adjustfly-config"

迁移

您需要迁移Adjustfly公开的调整表

php artisan migrate

Adjustfly路由

Adjustfly使用以下路由将此路由公开给您的应用程序。

    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使用方法

Adjustfly要求您在希望跟踪更新事件中调整的任何模型中使用此特性。

use Patrixsmart\Adjustfly\Traits\HasAdjustments;

class ModelClass extends Model
{
    use HasAdjustments;

    // This exposes this methods to the model
    // ModelClass->recordAdjustment() and ModelClass->adjustments()
}

并在您的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()
}

最后,在模型的静态更新或观察者更新事件方法中调用recordAdjustment方法,该模型具有Adjustments特性。

Adjustfly赞助商

我们非常感谢您对Adjustfly开发的赞助。如果您有兴趣成为赞助商,请通过package@patrixsmart.com联系PatriXsmarT LLC。

贡献

感谢您考虑为PatriXsmart Adjustfly做出贡献!

安全漏洞

如果您在Adjustfly中发现安全漏洞,请通过package@patrixsmart.com发送电子邮件给PatriXsmarT LLC。所有安全漏洞都将得到及时解决。

许可

PatriXsmarT Adjustfly是开源软件,采用MIT许可