Download the PHP package railken/eloquent-mapper without Composer

On this page you can find all versions of the php package railken/eloquent-mapper. 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 eloquent-mapper

Eloquent Mapper

Actions Status

A laravel package that use the full power of relations to create automatic joins and perform advanced filtering.

Given for e.g. two models Office and Employee, you can transform a string like this "employees.name ct 'Mario Rossi' or employees.name ct 'Giacomo'" into a sql query like this

Functions:

Requirements

PHP 8.1 and laravel 8

Installation

You can install it via Composer by typing the following command:

Usage

In order to use this library you need a map.

Create a new class wherever you want like the following example

app/Map.php

The method models must return a list of all models. You can even add models that are in your vendor folder, regardless of the logic you use, you only have to return an array.

Railken\EloquentMapper\Map also has the mapping of relations and attributes based on the model, if you wish you can ovveride that functionality and write your own. Check source

These methods are invoked only when you call the command artisan mapper:generate (see below) and the result will be cached in a file placed in bootstrap/cache/map.php.

This means you can perform whatever logic you want to retrieve all models (e.g. scanning files), so don't worry about caching.

Important: In order to be detected, all relations must return the type Illuminate\Database\Eloquent\Relations\Relation like this:

Now it's time to register this class in any provider to override the default one.

app/Providers/AppServiceProvider.php

Artisan

There is only one command, and it's artisan mapper:generate. This command will remap and recache so keep in mind that you have to execute it whanever you change your code models .

If you use models that are in your vendor folder, you could add this in your composer.json to reload everytime the libreries are updated.

Filtering

Sow how the filtering actually works?

And that's it! $query is now filtered, if Foo has any relationships you can use the dot notation and the filter will automatically perform the join. For e.g. if Foo has a relationship called tags and you want to retrieve all Foo with the tag name myCustomTag simply use tag.name = 'myCustomTag'.

Here's the full syntax

The third parameter is the eager loading option. You can of course use the dot notation as well and add subquery. For istance the following example rapresent a list of all authors that contains the name Mario and returns all of theirs books that have a tag.name called sci-fi.

Joiner

This is an internal class used by the FilterScope to join the necessary relations before performing the filtering, but you can use it indipendently. see tests

Example - Setup

Let's continue with a real example, first the setup. We will use two models: Office and Employee

app/Models/Office.php

app/Models/Employee.php

app/Map.php

Example - Usage

Retrieve all offices that have employees with name Mario Rossi or Giacomo

Result:


All versions of eloquent-mapper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
railken/bag Version ^2.0
ankurk91/laravel-eloquent-relationships Version ^2.1
railken/lara-eye Version 3.*
ramsey/collection Version ^2.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 railken/eloquent-mapper contains the following files

Loading the files please wait ....