Download the PHP package leko-team/laravel-published without Composer
On this page you can find all versions of the php package leko-team/laravel-published. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leko-team/laravel-published
More information about leko-team/laravel-published
Files in leko-team/laravel-published
Package laravel-published
Short Description Ready-made solution for publishing an entity
License MIT
Informations about the package laravel-published
Associate publishing with Eloquent models
This package can associate published date with Eloquent models. It provides a simple API to work with.
Installation
The library can be installed via Composer:
Configuration
To be able publishing eloquent entities you need:
- Add migration with column
published_at
or assignstatic::PUBLISHED_AT
constant with the name of the column you want to use.
If you have existing records in your table you maybe want to update them with current date. Or perhaps you want to add current date as default value.
- Add trait
PublishedTrait
to your model.
Examples
Base
To publish entity:
Publish by specific datetime:
To unpublish entity:
Scopes
By default from published entity return only published records. You can change this by applying scope to your Eloquent model.
- notPublished
Returns all not published record with null in published_at
include records that must be published in the future.
- withUnpublished
Returns all records.
- withoutPublished
Returns all unpublished record with null in published_at
.
Credits
A big thank you to Laravel Package for helping out build package with step by step guide.
License
The MIT License (MIT). Please see License File for more information.