PHPackages                             ritechoice23/laravel-saveable - 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. ritechoice23/laravel-saveable

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

ritechoice23/laravel-saveable
=============================

A flexible Laravel package for adding save/bookmark functionality to any model with collections, metadata, and ordering support.

1.0.0(6mo ago)1343↓100%[3 PRs](https://github.com/ritechoice23/laravel-saveable/pulls)1MITPHPPHP ^8.2CI passing

Since Nov 8Pushed 1mo agoCompare

[ Source](https://github.com/ritechoice23/laravel-saveable)[ Packagist](https://packagist.org/packages/ritechoice23/laravel-saveable)[ Docs](https://github.com/ritechoice23/laravel-saveable)[ GitHub Sponsors](https://github.com/ritechoice23)[ RSS](/packages/ritechoice23-laravel-saveable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (4)Used By (1)

Laravel Saveable
================

[](#laravel-saveable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/25a4b320f61882c2ef7fdbd876004d3d563c8f87ded50d450921d29ff2fd089f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7269746563686f69636532332f6c61726176656c2d7361766561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ritechoice23/laravel-saveable)[![GitHub Tests Action Status](https://camo.githubusercontent.com/89bc8c8d02976ac17dea1048777e2304bc133597cd37d79a447915dd2e006f87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7269746563686f69636532332f6c61726176656c2d7361766561626c652f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ritechoice23/laravel-saveable/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/0d01146ec4b72a4f47d502a388faf7d4bd101ff37757085f27601833dc2c5773/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7269746563686f69636532332f6c61726176656c2d7361766561626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ritechoice23/laravel-saveable)

A flexible Laravel package for adding save/bookmark functionality to any Eloquent model with collections, metadata, and custom ordering support. Perfect for building features like bookmarks, favorites, reading lists, and more!

Features
--------

[](#features)

- **Fully Polymorphic**: Any model can save any other model (User → Post, User → Article, etc.)
- **MorphMap Compatible**: Full support for both `Relation::morphMap()` and base class path configurations
- **Collections/Folders**: Organize saved items into nested collections
- **Metadata Support**: Add notes, priorities, or custom data to saves
- **Custom Ordering**: Control the order of saved items within collections
- **Simple API**: Intuitive methods like `saveItem()`, `unsaveItem()`, `toggleSaveItem()`, `hasSavedItem()`
- **Rich Queries**: Chainable query scopes and eager loading support
- **Zero Configuration**: Works out of the box with sensible defaults
- **Full Test Coverage**: Comprehensive Pest PHP test suite included

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Model Setup](#model-setup)
- [Basic Usage](#basic-usage)
- [Collection Management](#collection-management)
- [Retrieving Saved Items](#retrieving-saved-items)
- [Advanced Features](#advanced-features)
- [API Reference](#api-reference)
- [Testing](#testing)

Why This Package?
-----------------

[](#why-this-package)

### Popular Alternatives

[](#popular-alternatives)

- [maize-tech/laravel-markable](https://github.com/maize-tech/laravel-markable)
- [cybercog/laravel-love](https://github.com/cybercog/laravel-love) (bookmark feature)

### What Makes This Package Unique

[](#what-makes-this-package-unique)

✅ **Collections/Folders System** - Nested collections for organizing saved items (reading lists, watch later, favorites)

✅ **Order Management** - Custom ordering within collections with `order_column`

✅ **Metadata on Saves** - Notes, priorities, custom data on each save

✅ **Unsorted Items Management** - Dedicated methods for items saved without a collection

✅ **Mixed Models in Collections** - Save different model types in the same collection

✅ **Move Between Collections** - `moveSavedItem()` for reorganizing saved items

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

[](#installation)

Install the package via composer:

```
composer require ritechoice23/laravel-saveable
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="laravel-saveable-migrations"
php artisan migrate
```

Optionally, publish the config file:

```
php artisan vendor:publish --tag="laravel-saveable-config"
```

Configuration
-------------

[](#configuration)

The published config file (`config/saveable.php`) includes:

```
return [
    'saves_table' => 'saves',
    'collections_table' => 'collections',
    'auto_ordering' => true,
];
```

Model Setup
-----------

[](#model-setup)

Add the traits to your models to enable the "saver" and "saveable" functionality.

### 1. The "Saver" Model (e.g., User)

[](#1-the-saver-model-eg-user)

Add the `HasSaves` trait to any model that should be able to save things.

```
