News

Archive Eloquent Models with the “Archivable” Package

Published
Archive Eloquent Models with the “Archivable” Package image

The Laravel Archivable package by Joel Butcher is a simple package for making Eloquent models “archivable.” After adding the Archivable tait to your model(s), you have access to various macros:

$user = User::first();
 
// Archive a user
$user->archive();
// Remove user from the archive
$user->unArchive();
 
// Include archived users
$usersWithArchived = User::query()->withArchived();
 
// Only archived users
$onlyArchivedUsers = User::query()->onlyArchived();

Though the examples use the User model, this trait could be useful for things like a Ticket model or a Conversation model, or anywhere you have an archive feature to hide models from active model lists.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at joelbutcher/laravel-archivable.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in

Sponsored

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
Laravel Auditor Audits Your App With Your Own AI Agent image

Laravel Auditor Audits Your App With Your Own AI Agent

Read article
A simple form builder that stays out of your way image

A simple form builder that stays out of your way

Read article
Laravel AI: Trace Agent Runs With Lifecycle Events image

Laravel AI: Trace Agent Runs With Lifecycle Events

Read article
Laravel AI: Get Raw HTTP Responses and Rate Limits image

Laravel AI: Get Raw HTTP Responses and Rate Limits

Read article
Agent Run Observability in Laravel AI SDK 0.11 image

Agent Run Observability in Laravel AI SDK 0.11

Read article
Debounced Queued Event Listeners in Laravel image

Debounced Queued Event Listeners in Laravel

Read article