Download the PHP package austinw/laravel-union-paginator without Composer

On this page you can find all versions of the php package austinw/laravel-union-paginator. 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-union-paginator

UnionPaginator Documentation

Tests Linter Total Downloads Latest Stable Version License

Introduction

The UnionPaginator package enables you to paginate and unify results from multiple Eloquent models into a single dataset. By merging multiple model queries, it allows for straightforward pagination and sorting of data drawn from various sources.

Key Features:

Installation

Install via Composer:

Migration Guide

If you are upgrading from an earlier version of UnionPaginator, please refer to the Migration Guide for detailed instructions on updating your code to take advantage of the latest features and improvements.

Getting Started

Initializing the UnionPaginator

Specify which Eloquent models you want to combine:

All provided classes must be subclasses of Illuminate\Database\Eloquent\Model.

Paginating Data

Call paginate to get paginated results:

This returns a LengthAwarePaginator instance, seamlessly integrating with Laravel’s pagination utilities.

Applying Scopes to Individual Models

You can apply specific query conditions to a single model type before creating the union:

Customizing Mass Model Retrieval

The UnionPaginator class allows you to customize how models are retrieved during pagination. This can be useful if you need to apply specific logic or optimizations when fetching models from the database.

Registering a Custom Retrieval Callback

You can register a custom callback for retrieving models by type using the fetchModelsUsing method. This method allows you to define how models should be fetched for a specific model type.

Now only active users are included in the final union.

Important Considerations

By using custom retrieval callbacks, you can optimize and tailor the model fetching process to suit your application's specific needs.

Transforming Results

Use transformResultsFor to alter records for a particular model type:

If model retrieval is active, $user is an Eloquent model. If you call preventModelRetrieval(), $user is a raw database record (stdClass).

Preventing Model Retrieval

If you don’t need Eloquent models and prefer raw records:

Transformations still apply, but are run on raw records.

Selecting Columns

Choose specific columns for each model type to reduce overhead:

Soft Deletes

Models using SoftDeletes are automatically filtered so that soft-deleted records do not appear.

Methods

Example Usage

Advanced Usage

Ordering and Complex Queries

You can chain Eloquent methods before paginate():

or

Multiple Transformations for the Same Model

Applying multiple transformations for the same model type overwrites earlier ones:

The latter transformation takes precedence.

Handling Empty Results

If no matching records are found, the paginator returns an empty result set without errors.

Testing

UnionPaginator is well-tested across various scenarios, including:


All versions of laravel-union-paginator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/database Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/pagination Version ^10.0|^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 austinw/laravel-union-paginator contains the following files

Loading the files please wait ....