m74asoud / temptag
Laravel Temporary Tag for tagging Eloquent models - store in 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
Auto-expiring tags with additional payload data on any eloquent model.
Installation
first you need to install and configure mongodb in your laravel project with jenssegers/laravel-mongodb, then install package m74asoud/temptag with below command
composer require m74asoud/temptag
migrate table
php artisan migrate
Configure Model
use M74asoud\TempTag\Traits\TempTagAble; class User extend Model { use TempTagAble; protected $connection = 'mysql'; protected $table = 'users'; }
Usage
$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
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.