pawelmysior/laravel-publishable
Larablocks Analysis
pawelmysior/laravel-publishable works with Laravel 12 (latest release 5.0.0, Mar 31, 2025).
Laravel 5 to 11 in earlier releases.
Recommendation checks
Use with careUse with care: meets 0 of 4 checks.
- Latest release doesn't support Laravel 13, the current version
- No release in the last 12 months (last: Mar 31, 2025)
- 36 downloads a month (needs 10,000)
- 22 GitHub stars (needs 100)
State
Quiet- Last stable release: Mar 31, 2025.
- No releases in the last 12 months.
- First released: Jul 30, 2017.
- Monthly downloads: 36.
- 4 open issues on GitHub.
Data from Packagist and GitHub, checked by Larablocks on Nov 27, 2026.
| Install | |
|---|---|
composer require pawelmysior/laravel-publishable |
|
| Latest Version: | 5.0.0 |
| PHP: | ^8.2 |
| Laravel: | 12 |
| Older releases: | 5 – 11 |
| License: | MIT |
| Last Updated: | Mar 31, 2025 |
| Links: | GitHub · Packagist |
Publishable
Toggle the published state of your Eloquent models easily.
Installation
You can install the package via composer:
composer require pawelmysior/laravel-publishable
Versions
For details about which version of this package to use with your Laravel version please see the table below:
| Laravel Version | Package Version |
|---|---|
| <9.x | 1.x |
| 9.x | 2.x |
| 10.x | 3.x |
| 11.x | 4.x |
| 12.x | 5.x |
Preparation
To start you need to add a published_at nullable timestamp column to your table.
Put this in your table migration:
$table->timestamp('published_at')->nullable();
Now use the trait on the model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use PawelMysior\Publishable\Publishable;
class Post extends Model
{
use Publishable;
}
Add Fillable Attribute
In Version 1.x, the published() function handles the update in a way where Laravel expects that the published_at field is fillable. As of Version 2.x, we not use fill functionality so the fillable attribute is no longer required.
Usage
You can now use those features:
// Get only published posts
Post::published()->get();
// Get only unpublished posts
Post::unpublished()->get();
// Check if the post is published
$post->isPublished();
// Check if the post is unpublished
$post->isUnpublished();
// Publish the post
$post->publish();
// Unpublish the post
$post->unpublish();
// Publish the post without firing model events
$post->publishQuietly();
// Unpublish the post without firing model events
$post->unpublishQuietly();
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.
Security
If you discover any security-related issues, please email security@jaymeh.co.uk instead of using the issue tracker.
Contributing
Any contributions to this repository are welcomed. Please be aware that we are using conventional commits to assist in self documentation and reduce manual work involved with releases.
License
The MIT License (MIT). Please see License File for more information.
Related Packages
A Laravel Eloquent Model trait for adding a UUID to Eloquent Models
A Laravel Eloquent Model trait for adding User Id's to Eloquent Models
Trait for Laravel Eloquent models to allow easy implementation of delivering fea...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 5.0.0 | ^8.2 | ^12.0 | MIT | |
| 4.0.0 | ^8.2 | ^11.0 | MIT | |
| 3.0.0 | ^8.1 | ^10.0 | MIT | |
| 2.1.0 | ^8.0 | ^9.0 | MIT | |
| 2.0.0 | ^8.0 | ^9.0 | MIT | |
| 1.2.3 | >=5.6.4 | ~5.4.0| | MIT | |
| 1.2.2 | >=5.6.4 | ~5.4.0| | MIT | |
| 1.2.1 | >=5.6.4 | ~5.4.0| | MIT | |
| 1.2.0 | >=5.6.4 | ~5.4.0| | MIT | |
| 1.1.1 | >=5.6.4 | ^5.4 | MIT | |
| 1.1.0 | >=5.6.4 | ^5.4 | MIT | |
| 1.0.0 | >=5.6.4 | ^5.4 | MIT |