Download the PHP package clickbar/laravel-custom-relations without Composer

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

Laravel Custom Relations

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel provides some pretty good relations from scratch. If those relations do not fit the need, the community has provided a lot of other relation packages. Especially staudenmeir did a lot if nice work on that end. However, in our projects we encountered the need of some really custom relations that could easily be expressed with an eloquent query, but not with default relations. Therefore, we created this package to give you the full control over your relations.

Introduction

Sometimes it needs to be more custom. This package extends the default Laravel Relations with Relations that can be described by a query.

For explanation purposes we consider the following model with a simple concatenated relation use case. (for cases like this you should also have a look eloquent-has-many-deep from staudenmeir). Even the example is quite simple, it should be able to represent the huge amount of possibilities that comes with custom relations.

Let's explorer the connection between Client and Task in the default Laravel way:

Wouldn't it be cool to do stuff like this with only 1 single database query?

With Custom Relations you can do this with only one single Database Query.

Installation

You can install the package via composer:

Preparing the Model

In order to use the Custom Relations, you must use the HasCustomRelation trait:

Writing the Relation

Like you know from Laravel, relations can return a collection of models or just one model. Therefore, this package has two Different Relations CustomRelation and CustomRelationSingle.

Let's look at our two examples from above:

Like regular Laravel Relations, the query builder starts from the related model. This results in the following join chains:
$task->client: Client->Projects->Orders->Tasks
$client->tasks: Tasks->Orders->Projects->Client

If you prefer starting the join from the model the relation is defined on, you can use the method with the fromParent suffix:

Limitations

Since the query might introduce a lot of joins, some methods known from Laravel Relations are not available:

Testing

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-custom-relations with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^10.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 clickbar/laravel-custom-relations contains the following files

Loading the files please wait ....