PHPackages                             laravel-creative/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. laravel-creative/draftable

ActiveLibrary

laravel-creative/draftable
==========================

Laravel Drafts tool for models

v0.0.3(6y ago)62932[1 issues](https://github.com/laravel-creative/draftable/issues)MITPHPPHP ^7.1

Since Jul 16Pushed 6y ago1 watchersCompare

[ Source](https://github.com/laravel-creative/draftable)[ Packagist](https://packagist.org/packages/laravel-creative/draftable)[ Docs](https://github.com/laravel-creative/draftable)[ RSS](/packages/laravel-creative-draftable/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (2)Versions (4)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 laravel-creative/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 user

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

to assign the draft for specific user

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

To get all drafts for specific user

```
 $draftsArticles=Article::setUser($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() `

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

to publish the draft you can use `php   $draftsArticle->publish(); `

```
  $draftsArticles=Article::getUnPublishedDraft();
  foreach($draftsArticles as $draftsArticle)
  {
   $draftsArticle->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();
$articleDrafts=$article->drafts;
```

if you want Eloquent model for specific draft use `php $draft->model() `

```
$articleDrafts[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();
$articleDraft=$article->drafts()->first();
$articleDraft->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

25

—

LowBetter than 37% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

2490d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25182746?v=4)[Mustafa Khaled](/maintainers/mustafakhaleddev)[@mustafakhaleddev](https://github.com/mustafakhaleddev)

---

Top Contributors

[![mustafakhaleddev](https://avatars.githubusercontent.com/u/25182746?v=4)](https://github.com/mustafakhaleddev "mustafakhaleddev (15 commits)")

---

Tags

wordpressarchivelaravel-packagesdraftsdraftablerestore modelslaravel-creativeLaravel Wordpress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-creative-draftable/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-creative-draftable/health.svg)](https://phpackages.com/packages/laravel-creative-draftable)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.0k17.2M320](/packages/wp-cli-wp-cli)[wp-coding-standards/wpcs

PHP\_CodeSniffer rules (sniffs) to enforce WordPress coding conventions

2.7k42.5M1.6k](/packages/wp-coding-standards-wpcs)[composer/installers

A multi-framework Composer library installer

1.4k136.0M6.0k](/packages/composer-installers)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[orchestra/testbench-core

Testing Helper for Laravel Development

27043.7M310](/packages/orchestra-testbench-core)[phpcompatibility/phpcompatibility-wp

A ruleset for PHP\_CodeSniffer to check for PHP cross-version compatibility issues in projects, while accounting for polyfills provided by WordPress.

21830.6M587](/packages/phpcompatibility-phpcompatibility-wp)

PHPackages © 2026

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