-
-
Notifications
You must be signed in to change notification settings - Fork 20
Publishable model
Anton Komarev edited this page Mar 24, 2020
·
4 revisions
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasPublishedFlag;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasPublishedFlag;
}Model must have boolean is_published column in database table.
<?php
namespace App\Models;
use Cog\Flag\Traits\Classic\HasPublishedAt;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasPublishedAt;
}Model must have nullable timestamp published_at column in database table.
Post::all();
Post::withNotPublished()->get();Post::withoutNotPublished()->get();Post::onlyNotPublished()->get();Post::where('id', 4)->publish();Post::where('id', 4)->undoPublish();