Download the PHP package nascentafrica/eloquent-repository without Composer

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

Eloquent Repository

Eloquent Repository is used to abstract the data layer, making our application more flexible to maintain.

Many thanks to Anderson Andrade for this project is a stripped down version of andersao/l5-repository. This was done because i preferred to do my validations and transformations else where and not in my repository.

Installation

Composer

Execute the following command to get the latest version of the package:

Laravel

>= laravel5.5

ServiceProvider will be attached automatically

Other

In your config/app.php add NascentAfrica\EloquentRepository\RepositoryServiceProvider::class to the end of the providers array:

If Lumen

Publish Configuration

Methods

NascentAfrica\EloquentRepository\Contracts\RepositoryInterface

NascentAfrica\EloquentRepository\Contracts\RepositoryCriteriaInterface

NascentAfrica\EloquentRepository\Contracts\CacheableInterface

NascentAfrica\EloquentRepository\Contracts\CriteriaInterface

Usage

Create a Model

Create your model normally, but it is important to define the attributes that can be filled from the input form data.

Create a Repository

Generators

Create your repositories easily through the generator.

Config

You must first configure the storage location of the repository files. By default is the "app" folder and the namespace "App". Please note that, values in the namespaces array are actually used as both namespace and file paths.

You may want to save the root of your project folder out of the app and add another namespace, for example

Additionally, you may wish to customize where your generated classes end up being saved. That can be accomplished by editing the paths node to your liking. For example:

Commands

To generate everything you need for your Model, run this command:

This will create the Model if it does not exist, the Repository and the interface classes. It will also create a new RepositoryServiceProvider if it does not exist that will be used to bind the Eloquent Repository with its corresponding Repository Interface. To load it, just add this to your AppServiceProvider@register method:

When running the command, you will be creating the "Entities" folder and "Repositories" inside the folder that you set as the default.

Now that is done, you still need to bind its interface for your real repository, for example in your own Repositories Service Provider.

And use

Find all results in Repository

Find all results in Repository with pagination

Find by result by id

Hiding attributes of the model

Showing only specific attributes of the model

Loading the Model relationships

Find by result by field name

Find by result by multiple fields

Find by result by multiple values in one field

Find by result by excluding multiple values in one field

Find all using custom scope

Create new entry in Repository

Update entry in Repository

Delete entry in Repository

Delete entry in Repository by multiple fields

Create a Criteria

Using the command

Criteria are a way to change the repository of the query by applying specific conditions according to your needs. You can add multiple Criteria in your repository.

Using the Criteria in a Controller

Getting results from Criteria

Setting the default Criteria in Repository

Skip criteria defined in the repository

Use skipCriteria before any other chaining method

Popping criteria

Use popCriteria to remove a criteria

Using the RequestCriteria

RequestCriteria is a standard Criteria implementation. It enables filters to perform in the repository from parameters sent in the request.

You can perform a dynamic search, filter the data and customize the queries.

To use the Criteria in your repository, you can add a new criteria in the boot method of your repository, or directly use in your controller, in order to filter out only a few requests.

Enabling in your Repository

Remember, you need to define which fields from the model can be searchable.

In your repository set $fieldSearchable with the name of the fields to be searchable or a relation to fields.

You can set the type of condition which will be used to perform the query, the default condition is "="

Enabling in your Controller

Example the Criteria

Request all data without filter by request

http://localhost/users

Conducting research in the repository

http://localhost/users?search=John%20Doe

or

http://localhost/users?search=John&searchFields=name:like

or

http://localhost/[email protected]&searchFields=email:=

or

http://localhost/users?search=name:John Doe;email:[email protected]

or

http://localhost/users?search=name:John;email:[email protected]&searchFields=name:like;email:=

By default RequestCriteria makes its queries using the OR comparison operator for each query parameter. http://localhost/users?search=age:17;email:[email protected]

The above example will execute the following query:

In order for it to query using the AND, pass the searchJoin parameter as shown below:

http://localhost/users?search=age:17;email:[email protected]&searchJoin=and

Filtering fields

http://localhost/users?filter=id;name

Sorting the results

http://localhost/users?filter=id;name&orderBy=id&sortedBy=desc

Sorting through related tables

http://localhost/users?orderBy=posts|title&sortedBy=desc

Query will have something like this

http://localhost/users?orderBy=posts:custom_id|posts.title&sortedBy=desc

Query will have something like this

Add relationship

http://localhost/users?with=groups

Overwrite params name

You can change the name of the parameters in the configuration file config/repository.php

Cache

Add a layer of cache easily to your repository

Cache Usage

Implements the interface CacheableInterface and use CacheableRepository Trait.

Done , done that your repository will be cached , and the repository cache is cleared whenever an item is created, modified or deleted.

Cache Config

You can change the cache settings in the file config/repository.php and also directly on your repository.

config/repository.php

It is possible to override these settings directly in the repository.

The cacheable methods are : all, paginate, find, findByField, findWhere, getByCriteria

License

This software is released under The MIT License (MIT).


All versions of eloquent-repository with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2
illuminate/http Version ~5.0|~6.0|~7.0
illuminate/config Version ~5.0|~6.0|~7.0
illuminate/support Version ~5.0|~6.0|~7.0
illuminate/database Version ~5.0|~6.0|~7.0
illuminate/pagination Version ~5.0|~6.0|~7.0
illuminate/console Version ~5.0|~6.0|~7.0
illuminate/filesystem Version ~5.0|~6.0|~7.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 nascentafrica/eloquent-repository contains the following files

Loading the files please wait ....