Download the PHP package foothing/laravel-repository without Composer

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

Laravel repository

This package provides an implementation of the repository pattern for Laravel 5.

Composer installation

Basic usage

This package ships with a repository interface definition and an Eloquent implementation. The EloquentRepository is ready to use.

You are now ready to go:

If you want to extend the base implementation with your custom methods all you need to do is extend the base class and define a constructor with the Eloquent model as the first argument.

Don't forget to call the superclass constructor in order to enable all the features that are delivered out of the box. You can also add additional dependencies while overriding the base constructor.

and you are all set. Examples:

Eager load relations

You can eager load relations using the with method:

You can chain the with method to all available methods:

You'll often want to eager load some relations by default. Let's assume you have an User model with a many-to-many relation with its Role models, and you want to fetch both the user info and the roles.

The Foothing\Resources\Resource interface has three methods which define the default Model behaviour:

In this way, each time you will use your UserRepository the following would be the default behaviour:

This default behaviour will be ignored if you use the with method explicitly.

The skipOnSave method comes handy when dealing with JSON object, since when you read a resource, then process it on the client side, then send it back to the server, it will contain the relation properties. This properties will be converted to stdClass PHP object breaking the Eloquent save method.

Criteria

You can apply filters and order constraints using the CriteriaInterface, which also ships with an Eloquent implementation.

Usage:

The repository provides shortcut methods you can use in your chains. The following example produces the same effect as the previous one.

Available filters:

You can use the in operator with a comma separated list of values or with an array of values.

Nested filters

It's also possible to query a Model relation. Assume your Eloquent Model defines a children relation like so:

In this case you'll be allowed to query children values:

Keep in mind that the methods subject to criteria restrictions are all those fetching more than one record.

Attach and detach many-to-many

Given the following Model:

you can use the attach() and detach() methods to attach and detach to / from relation.

Scopes

You can plug-in your Model scopes using the scope() method.

Scopes only apply on read methods.

Global Scopes

You can define a global scope for each repository implementation, which might come handy to restrict records access globally.

Just set

in your repository. The global scope must match an Eloquent scope. Note that if you use explicit scopes, i.e. $repository->scope('male'), your global scope will be ignored.

Repository API

RemoteQuery

More info coming soon.

License

MIT


All versions of laravel-repository with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/database Version ~5.0
illuminate/support Version ~5.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 foothing/laravel-repository contains the following files

Loading the files please wait ....