Download the PHP package pawelmysior/laravel-publishable without Composer
On this page you can find all versions of the php package pawelmysior/laravel-publishable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pawelmysior/laravel-publishable
More information about pawelmysior/laravel-publishable
Files in pawelmysior/laravel-publishable
Package laravel-publishable
Short Description Toggle the published state of your Eloquent models easily
License MIT
Informations about the package laravel-publishable
Publishable
Toggle the published state of your Eloquent models easily.
Installation
You can install the package via composer:
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 |
Preparation
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
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:
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 [email protected] 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.