-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expirable model
Anton Komarev edited this page Mar 24, 2020
·
3 revisions
<?php
namespace App\Models;
use Cog\Flag\Traits\Inverse\HasExpiredFlag;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasExpiredFlag;
}
Model must have boolean is_expired
column in database table.
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasExpiredAt;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasExpiredAt;
}
Model must have nullable timestamp expired_at
column in database table.
Post::all();
Post::withExpired()->get();
Post::withoutExpired()->get();
Post::onlyExpired()->get();
Post::whereKey(4)->expire();
Post::whereKey(4)->undoExpire();