PHPackages                             cape-and-bay/draftable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cape-and-bay/draftable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

cape-and-bay/draftable
======================

Laravel Drafts tool for models

v1.3.3(3y ago)02.8k1MITPHPPHP ^8.1

Since Jan 9Pushed 3y agoCompare

[ Source](https://github.com/GymRevenue/draftable)[ Packagist](https://packagist.org/packages/cape-and-bay/draftable)[ Docs](https://github.com/GymRevenue/draftable)[ RSS](/packages/cape-and-bay-draftable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

Laravel Draftable Models
========================

[](#laravel-draftable-models)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f406c67a5b633bf097a4d6aae429525a97740816ca7855ee03101cccbc31d476/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d63726561746976652f647261667461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-creative/draftable)[![Total Downloads](https://camo.githubusercontent.com/3331e3b9ad82020bed63c0b77b1b33033be28d0b5e1c092859654b9f66e643d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d63726561746976652f647261667461626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-creative/draftable)

Bring the power of Wordpress drafts posts to your Laravel application , with simple functions and steps

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require CapeAndBay/draftable
```

after installing the package go a head and run migrate.

```
php artisan migrate
```

In your model add

```
use DraftableModel;
```

Usage
-----

[](#usage)

#### Save model as draft

[](#save-model-as-draft)

to save the model as draft you can use `php $model->saveAsDraft() ` method

```
 $faker = Factory::create();
 $article = new Article();
 $article->title = $faker->paragraph(1);
 $article->content = $faker->paragraph;
 $article->saveAsDraft();
```

in case you want to save it in its own table but also you need to make a draft of this update you can use

```
$article->saveWithDraft();
```

#### Assign the draft for owner

[](#assign-the-draft-for-owner)

to assign the draft for specific owner

```
$article::setOwner($user);
```

To get all drafts for specific owner

```
 $draft_articles = Article::setOwner($user)->getAllDrafts();
```

#### Save data with the draft

[](#save-data-with-the-draft)

you can save data with the draft like (publish\_date) or anything else.

```
$article->saveAsDraft();
$article->draft->setData('publish_date', Carbon::now()->addDay());
//you can get the data with this method
$article->draft->getData('publish_date');
```

#### Get Drafts for model

[](#get-drafts-for-model)

To get all drafts for the model use `php Model::getAllDrafts() `

```
 $drafts = Article::getAllDrafts();
```

to get published drafts only use `php Model::getPublishedDraft() `

```
 $publishedDrafts = Article::getPublishedDraft();
```

to get unpublished drafts only use `php Model::getUnPublishedDraft() `

```
 $unpublished_draft_articles = Article::getUnPublishedDraft();
```

to publish the draft you can use

```
$draft_articles->publish();

# Publish all drafts
$draft_articles = Article::getUnPublishedDraft();
foreach($draft_articles as $draft_articles) {
    $draft_articles->publish();
}
```

#### Get drafts for saved model

[](#get-drafts-for-saved-model)

once you saved the model with

```
$article->saveWithDraft();
```

you can access all drafts for this model with this method

```
$article = Article::first();
dump($article->drafts);
```

if you want Eloquent model for specific draft use

```
$draft->model()
#
$article_drafts[0]->model()
```

#### Restore specific draft for stored model

[](#restore-specific-draft-for-stored-model)

after selecting the draft for the model and you want to restore it as current published one you can use `php $draft->restore() `

```
$article = Article::first();
$article_draft = $article->drafts()->first();
$article_draft->restore();
```

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mustafa Khaled](https://github.com/mustafakhaleddev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Total

6

Last Release

1098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4efbf94b35bb601103d3f8343cadc4656414ae5ae396410d7d444d56f580e571?d=identicon)[cnb](/maintainers/cnb)

---

Top Contributors

[![mustafakhaleddev](https://avatars.githubusercontent.com/u/25182746?v=4)](https://github.com/mustafakhaleddev "mustafakhaleddev (15 commits)")[![chrys-u](https://avatars.githubusercontent.com/u/112005953?v=4)](https://github.com/chrys-u "chrys-u (10 commits)")[![Ghostff](https://avatars.githubusercontent.com/u/15882122?v=4)](https://github.com/Ghostff "Ghostff (1 commits)")

---

Tags

archivelaravel-packagesdraftsdraftablerestore modelscapeandbay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cape-and-bay-draftable/health.svg)

```
[![Health](https://phpackages.com/badges/cape-and-bay-draftable/health.svg)](https://phpackages.com/packages/cape-and-bay-draftable)
```

###  Alternatives

[oddvalue/laravel-drafts

A simple, drop-in drafts/revisions system for Laravel models

423196.1k2](/packages/oddvalue-laravel-drafts)[gemorroj/archive7z

7z cli wrapper

103963.0k1](/packages/gemorroj-archive7z)[vildanbina/laravel-versions

A Laravel package for managing model drafts.

333.3k](/packages/vildanbina-laravel-versions)[dmitrirussu/rjson-php

Compress array collection data to json

143.8k](/packages/dmitrirussu-rjson-php)[entrepreneur-interet-general/bulletins

Bulletins is a simple weekly retrospective tool for multiple projects or teams

122.6k](/packages/entrepreneur-interet-general-bulletins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
