-
-
Notifications
You must be signed in to change notification settings - Fork 21
Closable model
Anton Komarev edited this page Mar 24, 2020
·
3 revisions
<?php
namespace App\Models;
use Cog\Flag\Traits\Inverse\HasClosedFlag;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasClosedFlag;
}
Model must have boolean is_closed
column in database table.
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasClosedAt;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasClosedAt;
}
Model must have nullable timestamp closed_at
column in database table.
Post::all();
Post::withClosed()->get();
Post::withoutClosed()->get();
Post::onlyClosed()->get();
Post::whereKey(4)->close();
Post::whereKey(4)->undoClose();