m74asoud / temptag
Laravel 临时标签库,用于标记 Eloquent 模型 - 存储于 mongodb
v0.0.2
2021-09-16 14:44 UTC
Requires
- php: ^8.0
- illuminate/database: ^8.0
- illuminate/support: ^8.0
- jenssegers/mongodb: ^3.8
README
自动过期标签,带有任何 Eloquent 模型的附加有效载荷数据。
安装
首先,您需要在您的 Laravel 项目中安装并配置 mongodb,使用 jenssegers/laravel-mongodb,然后使用以下命令安装包 m74asoud/temptag
composer require m74asoud/temptag
迁移表
php artisan migrate
配置模型
use M74asoud\TempTag\Traits\TempTagAble; class User extend Model { use TempTagAble; protected $connection = 'mysql'; protected $table = 'users'; }
使用方法
$user->tempTagService() ->tagIt( string $title, $payload = null, Carbon $expire_at = null ): TempTag $user->tempTagService()->unTag(string $title) $user->tempTagService()->unTagID($ID) $user->tempTagService()->get(string $title): EloquentCollection $user->tempTagService()->getOne(string $title): ?TempTag $user->tempTagService()->getOneID($ID): ?TempTag $user->tempTagService()->all(): EloquentCollection ... and another method,complete readme file comming soon
贡献
欢迎 Pull requests。对于重大更改,请先打开一个问题进行讨论,您想进行哪些更改。