Download the PHP package ritechoice23/laravel-saveable without Composer

On this page you can find all versions of the php package ritechoice23/laravel-saveable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-saveable

Laravel Saveable

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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

Table of Contents

Why This Package?

Popular Alternatives

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

Install the package via composer:

Publish and run the migrations:

Optionally, publish the config file:

Configuration

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

Model Setup

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

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

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

2. The "Saveable" Model (e.g., Post)

Add the IsSaveable trait to any model that you want to be saveable.

Basic Usage

Saving & Unsaving

All methods are called from the "saver" model (e.g., your User instance).

Save an item:

Unsave an item:

Toggle a save:

Check if an item is saved:

You can also check from the "saveable" model:

Count how many times an item has been saved:

Collection Management

Creating Collections

Collections are owned by a "saver" (typically a User).

Create a top-level collection:

Create a nested collection:

Saving to Collections

Pass the collection as the second argument to the saveItem method.

Retrieving Collections & Items

Get all collections for a user:

Get only top-level (root) collections:

Get a collection's children (sub-folders):

Get a collection's parent:

Get all saved items within a collection:

Move a saved item to a different collection:

Retrieving Saved Items

Get all "save" records for a user:

This returns the Save model instances, which include metadata.

Get all saved items as a query (single type):

This returns a Builder so you can chain additional queries.

Get saved items grouped by type:

Perfect for when users save multiple model types.

Get all unsorted items:

This gets items that were saved without a collection.

Get all users who saved a specific item:

Count saved items:

Advanced Features

Metadata

You can add extra data (like notes) to a save. This is stored in a JSON column on the saves table.

Save with metadata:

Update metadata on an existing save:

Retrieve metadata:

Ordering

The saves table has an order_column (integer). When a user saves an item, it's automatically given the next available number for its scope (user + collection).

You can retrieve items in this order:

Query Scopes

Eager load save counts:

Get most saved posts:

Check save status for current user:

Filter posts saved by a user:

Filter users who saved a specific post:

API Reference

HasSaves Trait Methods

Method Parameters Return Description
saveItem() Model $model, ?Collection $collection, array $metadata bool Save an item with optional collection/metadata
unsaveItem() Model $model bool Unsave an item
toggleSaveItem() Model $model, ?Collection $collection, array $metadata bool Toggle save status
hasSavedItem() Model $model bool Check if has saved a model
getSavedRecord() Model $model ?Save Get the save record for a model
moveSavedItem() Model $model, ?Collection $collection bool Move a save to a different collection
updateSavedItemMetadata() Model $model, array $metadata bool Update metadata on a save
savedItems() ?string $type Builder Get saved items query (chainable)
savedItemsOfType() string $type Builder Get saved items of specific type
savedItemsGrouped() - Collection Get saved items grouped by type
unsortedSavedRecords() - Collection Get unsorted Save records
unsortedSavedItems() ?string $type Builder Get unsorted items query
savedItemsCount() ?string $type int Count saved items
savedRecords() - MorphMany Relationship: all Save records
collections() - HasMany Relationship: all collections owned
rootCollections() - HasMany Relationship: root collections

HasSaves Trait Scopes

Scope Parameters Description
whereSavedItem() Model $model Filter by models that saved an item

IsSaveable Trait Methods

Method Parameters Return Description
timesSaved() - int Total number of saves
isSavedBy() Model $saver bool Check if saved by a specific model
savedRecordBy() Model $saver ?Save Get save record by a specific model
savers() ?string $type Builder Get savers query (chainable)
saversGrouped() - Collection Get savers grouped by type
removeSavedBy() Model $saver bool Remove a specific model's save
saversCount() ?string $type int Count savers
saveRecords() - MorphMany Relationship: all Save records

IsSaveable Trait Scopes

Scope Parameters Description
withSavesCount() - Eager load save count
mostSaved() int $limit = 10 Order by most saved
withSaveStatus() Model $saver Add save status for a specific saver
whereSavedBy() Model $saver Filter by saved by a saver

Practical Examples

Building a Bookmark Feature

User's Saved Items Dashboard

Popular Posts

Get Saved Posts with Filtering

Testing

Run the test suite:

Run tests with coverage:

Run static analysis:

Run code formatting:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-saveable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ritechoice23/laravel-saveable contains the following files

Loading the files please wait ...