Download the PHP package reedware/laravel-composite-relations without Composer

On this page you can find all versions of the php package reedware/laravel-composite-relations. 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-composite-relations

Laravel Composite Relations

Laravel Version Tests Lint Static Analysis

This package adds the ability to have multiple foreign keys in a relation.

Introduction

Eloquent does not natively support using composite keys in relationships. While single key relationships are typically preferred, there are times where they are unfortunately needed, and there's good way around it. This package offers a solution where you can use composite keys, and everything still feels like it's Eloquent.

This package will allow you to define the following composite relations:

All composite relations support eager loading and existence queries (e.g. "where has").

There currently is no intention to add support for additional relations, as these should be enough for the vast majority of use cases.

Installation

Using Composer

Versioning

This package is maintained with the latest version of Laravel in mind, but support follows Laravel's Support Policy.

Package Laravel PHP
4.x 10.x - 11.x 8.1 - 8.3+
3.x 8.x - 10.x 7.2 - 8.0+
2.x 6.x - 8.x 7.2 - 8.0+
1.x 5.5 - 5.8 7.1 - 7.3+

Code Changes

This package does not use a service provider or facade, but rather a trait. On your base model instance, you'll want to include the following:

Usage

1. Defining Relations

Composite Belongs To

Imagine you were defining a non-composite belongs to relation:

Since composite relations use multiple keys, you'll simply define the keys as an array:

Composite Has One

This follows the same structure as the composite belongs to relation:

Composite Has Many

The pattern continues:

2. Omitting Foreign and Local Keys

With non-composite relationships, you aren't actually required to provide the foreign and local key, assuming you follow a certain convention. This functionality is also available for composite relations, but must be defined differently. Here's how:

3. Joining through Composite Relations

This package is compatible with reedware/laravel-relation-joins, meaning you can join through composite relations just like anything else:

You must separately include reedware/laravel-relation-joins for this to work.

4. Using composite and glue

The default glue between composite keys is 'or'. Meaning your query will be like:

You can change that by passing 'and' for the glue parameter:

Giving this result :


All versions of laravel-composite-relations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/database Version ^10.48|^11.0
illuminate/support Version ^10.48|^11.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 reedware/laravel-composite-relations contains the following files

Loading the files please wait ....