PHPackages                             joelbutcher/laravel-archivable - 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. [Database &amp; ORM](/categories/database)
4. /
5. joelbutcher/laravel-archivable

ActiveLibrary[Database &amp; ORM](/categories/database)

joelbutcher/laravel-archivable
==============================

An archivable trait package for Laravel Eloquent models

v1.12.0(1y ago)126622.9k↓16.8%24[1 issues](https://github.com/joelbutcher/laravel-archivable/issues)3MITPHPPHP ^7.3|^8.0CI failing

Since Oct 7Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/joelbutcher/laravel-archivable)[ Packagist](https://packagist.org/packages/joelbutcher/laravel-archivable)[ Docs](https://github.com/joelbutcher/laravel-archivable)[ RSS](/packages/joelbutcher-laravel-archivable/feed)WikiDiscussions 1.x Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (15)Used By (3)

[![Laravel Archivable](https://camo.githubusercontent.com/deb90fd18e284ec6743b35ecebf229a3371370df94ad5d22a4a735fc4182d71c/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323041726368697661626c652e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6a6f656c627574636865722532466c61726176656c2d61726368697661626c65267061747465726e3d617263686974656374267374796c653d7374796c655f32266465736372697074696f6e3d416e2b61726368697661626c652b74726169742b666f722b4c61726176656c2b456c6f7175656e742b6d6f64656c73266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d323030707826696d616765733d61726368697665267769647468733d37303026686569676874733d373030)](https://camo.githubusercontent.com/deb90fd18e284ec6743b35ecebf229a3371370df94ad5d22a4a735fc4182d71c/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c25323041726368697661626c652e706e673f7468656d653d6461726b267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d6a6f656c627574636865722532466c61726176656c2d61726368697661626c65267061747465726e3d617263686974656374267374796c653d7374796c655f32266465736372697074696f6e3d416e2b61726368697661626c652b74726169742b666f722b4c61726176656c2b456c6f7175656e742b6d6f64656c73266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d323030707826696d616765733d61726368697665267769647468733d37303026686569676874733d373030)

[![Build Status](https://github.com/joelbutcher/laravel-archivable/workflows/tests/badge.svg)](https://github.com/joelbutcher/laravel-archivable/actions)[![](https://camo.githubusercontent.com/f85c285e8dd71e3a9a13d8d2ae524f8a3956fa28f60bcbc633ad5fab70896093/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3330313939333630362f736869656c643f7374796c653d666c6174)](https://github.styleci.io/repos/301993606)[![Total Downloads](https://camo.githubusercontent.com/78d1fb93cd90fcdd4110e753f7b5158d4b2175589621e247288295a22774f4cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6f656c627574636865722f6c61726176656c2d61726368697661626c65)](https://packagist.org/packages/joelbutcher/laravel-archivable)[![Latest Stable Version](https://camo.githubusercontent.com/a83d3369d5f3c926956dada42800ed2a1949d54ca24ebb519dfb1ab7534dda29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f656c627574636865722f6c61726176656c2d61726368697661626c65)](https://packagist.org/packages/joelbutcher/laravel-archivable)[![License](https://camo.githubusercontent.com/7d656d6f10917f2fce3b8da923b2d67afe78a5a9f352c8cf9680e9e0388ad468/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6f656c627574636865722f6c61726176656c2d61726368697661626c65)](https://packagist.org/packages/joelbutcher/laravel-archivable)

A simple package for making Laravel Eloquent models 'archivable'. This package allows for the easy archiving of models by creating various macros to be used within method chaining.

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

[](#installation)

You can install the package via composer:

```
composer require joelbutcher/laravel-archivable
```

Usage
-----

[](#usage)

#### Migrations

[](#migrations)

The `Archivable` trait works similarly to Laravel's `SoftDeletes` trait. This package also ships with a helpful macro for Laravel's `\Illuminate\Database\Schema\Blueprint`. To get started, simply add the `archivedAt` macro to your migration, like so:

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->unsignedBigInteger('user_id');
    $table->string('title');
    $table->timestamps();
    $table->archivedAt(); // Macro
});
```

##### Rollback

[](#rollback)

```
Schema::create('posts', function (Blueprint $table) {
    $table->dropArchivedAt();
});
```

#### Eloquent

[](#eloquent)

You can now, safely, include the `Archivable` trait in your Eloquent model:

```
namespace App\Models;

use \Illuminate\Database\Eloquent\Model;
use \LaravelArchivable\Archivable;

class Post extends Model {

    use Archivable;
    ...
}
```

#### Extensions

[](#extensions)

The extensions shipped with this trait include; `archive`, `unArchive`, `isArchived`, `withArchived`, `withoutArchived`, `onlyArchived` and can be used accordingly:

```
$user = User::first();
$user->archive();
$user->unArchive();

// Check Archive status
$user->isArchived();

$usersWithArchived = User::query()->withArchived();
$onlyArchivedUsers = User::query()->onlyArchived();
```

By default, the global scope of this trait uses the `withoutArchived` extension when the trait is added to a model.

#### Archived models in route implicit binding

[](#archived-models-in-route-implicit-binding)

Typically, implicit model binding will not retrieve models that have been archived. However, you may instruct the implicit binding to retrieve these models by chaining the withArchived method onto your route's definition:

```
use App\Models\User;

Route::get('/users/{user}', function (User $user) {
    return $user->email;
})->withArchived();
```

### 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)

- [Joel Butcher](https://github.com/joelbutcher)

License
-------

[](#license)

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

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance69

Regular maintenance activity

Popularity54

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 55.8% 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 ~158 days

Recently: every ~208 days

Total

14

Last Release

41d ago

PHP version history (2 changes)v1.0.0PHP ^7.3|^7.4

v1.1.2PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb6903ee363d9201681e47a2dcbe12148b7d299dd9e37229cad774ecd923fd6e?d=identicon)[joelbutcher](/maintainers/joelbutcher)

---

Top Contributors

[![joelbutcher](https://avatars.githubusercontent.com/u/7163152?v=4)](https://github.com/joelbutcher "joelbutcher (24 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (9 commits)")[![grantjanecek](https://avatars.githubusercontent.com/u/17169721?v=4)](https://github.com/grantjanecek "grantjanecek (4 commits)")[![omaratpxt](https://avatars.githubusercontent.com/u/3249754?v=4)](https://github.com/omaratpxt "omaratpxt (1 commits)")[![rvzug](https://avatars.githubusercontent.com/u/7152234?v=4)](https://github.com/rvzug "rvzug (1 commits)")[![cyrillkalita](https://avatars.githubusercontent.com/u/2401848?v=4)](https://github.com/cyrillkalita "cyrillkalita (1 commits)")[![wajihkm](https://avatars.githubusercontent.com/u/18402145?v=4)](https://github.com/wajihkm "wajihkm (1 commits)")[![Joel-Jensen](https://avatars.githubusercontent.com/u/60270137?v=4)](https://github.com/Joel-Jensen "Joel-Jensen (1 commits)")[![Kaylakaze](https://avatars.githubusercontent.com/u/1363591?v=4)](https://github.com/Kaylakaze "Kaylakaze (1 commits)")

---

Tags

laravellaravel-archivable

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joelbutcher-laravel-archivable/health.svg)

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

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k43.2M632](/packages/spatie-laravel-medialibrary)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M345](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k32.6M46](/packages/kirschbaum-development-eloquent-power-joins)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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