Package Data | |
---|---|
Maintainer Username: | chrisbratherton |
Maintainer Contact: | chris@seriousjelly.com (Chris Bratherton) |
Package Create Date: | 2015-11-05 |
Package Last Update: | 2017-03-16 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 03:00:56 |
Package Statistics | |
---|---|
Total Downloads: | 285 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 2 |
Total Watchers: | 2 |
Total Forks: | 4 |
Total Open Issues: | 0 |
Easily add status to your models in Laravel 5.
Install the seriousjelly/laravel-draftable
package via composer:
$ composer require seriousjelly/laravel-draftable
Add the service provider (config/app.php
for Laravel 5):
# Add the service provider to the `providers` array
'providers' => array(
...
'Seriousjelly\Draftable\ServiceProvider',
)
Ensure that your migrations contain a status
column by copy & pasting the below into your table migration file:
# Add a status column to the table, feel free to change the default value.
$table->boolean('status')->default(0);
Your models should use Draftable's trait:
use Seriousjelly\Draftable\DraftableTrait;
class MyModel extends Model
{
use Draftable;
}
Your model is now draftable!
By default all records that have a status of 0 will be excluded from your query results. To include draft records, all you need to do is call the withDrafts()
method on your query.
// Returns only live data
Posts::get();
//Returns live & draft data
Posts::withDrafts()->get();
status
column on a table you choose (i.e php artisan draftable:table table_name
.Laravel-Draftable was written by Chris Bratherton and released under the MIT License. See the LICENSE file for details.
Copyright 2015 Chris Bratherton