findyouractivity / laravel-userstamps
此包已被弃用且不再维护。未建议替代包。
将 created_by, updated_by 和 deleted_by 添加到模型的包。
0.0.10
2022-03-22 18:32 UTC
Requires
- php: ^7.2|^8.0
- laravel/framework: ^5.6|^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- doctrine/dbal: ^2.6
- larapack/dd: ^1.0
- orchestra/testbench: ^7.2
- phpunit/phpunit: ^9.5.10
This package is auto-updated.
Last update: 2023-12-22 22:59:26 UTC
README
提供 Eloquent 特性,以自动维护当前登录用户在模型上创建、更新和删除(当使用 softDeletes 时)的 created_by、updated_by 和 deleted_by。
安装和用法
此包需要 PHP 7.2 和 Laravel 5.6 或更高版本。在控制台运行以下命令来安装包;
composer require findyouractivity/laravel-userstamps
您可以使用以下命令发布配置文件;
php artisan vendor:publish --provider="Sqits\UserStamps\UserStampsServiceProvider" --tag="config"
这是已发布配置文件的内容
return [ /* * Define the table which is used in the database to retrieve the users */ 'users_table' => 'users', /* * Define the table column type which is used in the table schema for * the id of the user * * Options: increments, bigIncrements, uuid * Default: bigIncrements */ 'users_table_column_type' => 'bigIncrements', /* * Define the name of the column which is used in the foreign key reference * to the id of the user */ 'users_table_column_id_name' => 'id', /* * Define the mmodel which is used for the relationships on your models */ 'users_model' => \App\Models\User::class, /* * Define the column which is used in the database to save the user's id * which created the model. */ 'created_by_column' => 'created_by', /* * Define the column which is used in the database to save the user's id * which updated the model. */ 'updated_by_column' => 'updated_by', /* * Define the column which is used in the database to save the user's id * which deleted the model. */ 'deleted_by_column' => 'deleted_by', ];
将宏添加到您的模型迁移中
public function up() { Schema::create('table_name', function (Blueprint $table) { ... $table->userstamps(); $table->softUserstamps(); }); }
将特性添加到您的模型中
use Sqits\UserStamps\Concerns\HasUserStamps; class Example extends Model { use HasUserStamps; }
将提供方法来检索执行创建、更新或删除操作的用户对象
$model->author; // the user who created the model $model->editor; // the user who last updated the model $model->destroyer; // the user who deleted the model
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
安全
如果您发现任何与安全相关的问题,请通过 电子邮件 发送至 info@sqits.nl,而不是使用问题跟踪器。
致谢
许可
MIT 许可证(MIT)。请参阅 许可文件 了解更多信息。