-
-
Notifications
You must be signed in to change notification settings - Fork 21
Approvable model
Anton Komarev edited this page Mar 24, 2020
·
3 revisions
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasApprovedFlag;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasApprovedFlag;
}
Model must have boolean is_approved
column in database table.
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasApprovedAt;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasApprovedAt;
}
Model must have nullable timestamp approved_at
column in database table.
Post::all();
Post::withNotApproved()->get();
Post::withoutNotApproved()->get();
Post::onlyNotApproved()->get();
Post::whereKey(4)->approve();
Post::whereKey(4)->undoApprove();