Toggle the published state of your Eloquent models easily
Toggle the published state of your Eloquent models easily.
You can install the package via composer:
composer require pawelmysior/laravel-publishable
To start you need to add a
published_at nullable timestamp column to your table.
Put this in your table migration:
Now use the trait on the model
class Post extends Model
You can now use those features:
// Get only published posts
// Get only unpublished posts
// Check if the post is published
// Check if the post is unpublished
// Publish the post
// Unpublish the post
A post is considered published when the
published_at is not null and in the past.
A post is considered unpublished when the
published_at is null or in the future.
The MIT License (MIT). Please see License File for more information.