Laravel 5 Repositories is used to abstract the data layer, making our application more flexible to maintain.

Overview

Laravel 5 Repositories

Laravel 5 Repositories is used to abstract the data layer, making our application more flexible to maintain.

Latest Stable Version Total Downloads Latest Unstable Version License Analytics Code Climate

See versions: 1.0.* / 2.0.*

Migrate to: 2.0 / 2.1

You want to know a little more about the Repository pattern? Read this great article.

Table of Contents

Installation

Composer

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

composer require prettus/l5-repository

Laravel

>= laravel5.5

ServiceProvider will be attached automatically

Other

In your config/app.php add Prettus\Repository\Providers\RepositoryServiceProvider::class to the end of the providers array:

'providers' => [
    ...
    Prettus\Repository\Providers\RepositoryServiceProvider::class,
],

If Lumen

$app->register(Prettus\Repository\Providers\LumenRepositoryServiceProvider::class);

Publish Configuration

php artisan vendor:publish --provider "Prettus\Repository\Providers\RepositoryServiceProvider"

Methods

Prettus\Repository\Contracts\RepositoryInterface

  • all($columns = array('*'))
  • first($columns = array('*'))
  • paginate($limit = null, $columns = ['*'])
  • find($id, $columns = ['*'])
  • findByField($field, $value, $columns = ['*'])
  • findWhere(array $where, $columns = ['*'])
  • findWhereIn($field, array $where, $columns = [*])
  • findWhereNotIn($field, array $where, $columns = [*])
  • findWhereBetween($field, array $where, $columns = [*])
  • create(array $attributes)
  • update(array $attributes, $id)
  • updateOrCreate(array $attributes, array $values = [])
  • delete($id)
  • deleteWhere(array $where)
  • orderBy($column, $direction = 'asc');
  • with(array $relations);
  • has(string $relation);
  • whereHas(string $relation, closure $closure);
  • hidden(array $fields);
  • visible(array $fields);
  • scopeQuery(Closure $scope);
  • getFieldsSearchable();
  • setPresenter($presenter);
  • skipPresenter($status = true);

Prettus\Repository\Contracts\RepositoryCriteriaInterface

  • pushCriteria($criteria)
  • popCriteria($criteria)
  • getCriteria()
  • getByCriteria(CriteriaInterface $criteria)
  • skipCriteria($status = true)
  • getFieldsSearchable()

Prettus\Repository\Contracts\CacheableInterface

  • setCacheRepository(CacheRepository $repository)
  • getCacheRepository()
  • getCacheKey($method, $args = null)
  • getCacheTime()
  • skipCache($status = true)

Prettus\Repository\Contracts\PresenterInterface

  • present($data);

Prettus\Repository\Contracts\Presentable

  • setPresenter(PresenterInterface $presenter);
  • presenter();

Prettus\Repository\Contracts\CriteriaInterface

  • apply($model, RepositoryInterface $repository);

Prettus\Repository\Contracts\Transformable

  • transform();

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.

namespace App;

class Post extends Eloquent { // or Ardent, Or any other Model Class

    protected $fillable = [
        'title',
        'author',
        ...
     ];

     ...
}

Create a Repository

namespace App;

use Prettus\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    /**
     * Specify Model class name
     *
     * @return string
     */
    function model()
    {
        return "App\\Post";
    }
}

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 paths array are acutally used as both namespace and file paths. Relax though, both foreward and backward slashes are taken care of during generation.

    ...
    'generator'=>[
        'basePath'=>app()->path(),
        'rootNamespace'=>'App\\',
        'paths'=>[
            'models'       => 'Entities',
            'repositories' => 'Repositories',
            'interfaces'   => 'Repositories',
            'transformers' => 'Transformers',
            'presenters'   => 'Presenters',
            'validators'   => 'Validators',
            'controllers'  => 'Http/Controllers',
            'provider'     => 'RepositoryServiceProvider',
            'criteria'     => 'Criteria',
        ]
    ]

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

    ...
     'generator'=>[
        'basePath'      => base_path('src/Lorem'),
        'rootNamespace' => 'Lorem\\'
    ]

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:

    'generator'=>[
        'basePath'=>app()->path(),
        'rootNamespace'=>'App\\',
        'paths'=>[
            'models'=>'Models',
            'repositories'=>'Repositories\\Eloquent',
            'interfaces'=>'Contracts\\Repositories',
            'transformers'=>'Transformers',
            'presenters'=>'Presenters'
            'validators'   => 'Validators',
            'controllers'  => 'Http/Controllers',
            'provider'     => 'RepositoryServiceProvider',
            'criteria'     => 'Criteria',
        ]
    ]

Commands

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

php artisan make:entity Post

This will create the Controller, the Validator, the Model, the Repository, the Presenter and the Transformer classes. It will also create a new service provider 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:

    $this->app->register(RepositoryServiceProvider::class);

You can also pass the options from the repository command, since this command is just a wrapper.

To generate a repository for your Post model, use the following command

php artisan make:repository Post

To generate a repository for your Post model with Blog namespace, use the following command

php artisan make:repository "Blog\Post"

Added fields that are fillable

php artisan make:repository "Blog\Post" --fillable="title,content"

To add validations rules directly with your command you need to pass the --rules option and create migrations as well:

php artisan make:entity Cat --fillable="title:string,content:text" --rules="title=>required|min:2, content=>sometimes|min:10"

The command will also create your basic RESTfull controller so just add this line into your routes.php file and you will have a basic CRUD:

Route::resource('cats', CatsController::class);

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.

App::bind('{YOUR_NAMESPACE}Repositories\PostRepository', '{YOUR_NAMESPACE}Repositories\PostRepositoryEloquent');

And use

public function __construct({YOUR_NAMESPACE}Repositories\PostRepository $repository){
    $this->repository = $repository;
}

Alternatively, you could use the artisan command to do the binding for you.

php artisan make:bindings Cats

Use methods

namespace App\Http\Controllers;

use App\PostRepository;

class PostsController extends BaseController {

    /**
     * @var PostRepository
     */
    protected $repository;

    public function __construct(PostRepository $repository){
        $this->repository = $repository;
    }

    ....
}

Find all results in Repository

$posts = $this->repository->all();

Find all results in Repository with pagination

$posts = $this->repository->paginate($limit = null, $columns = ['*']);

Find by result by id

$post = $this->repository->find($id);

Hiding attributes of the model

$post = $this->repository->hidden(['country_id'])->find($id);

Showing only specific attributes of the model

$post = $this->repository->visible(['id', 'state_id'])->find($id);

Loading the Model relationships

$post = $this->repository->with(['state'])->find($id);

Find by result by field name

$posts = $this->repository->findByField('country_id','15');

Find by result by multiple fields

$posts = $this->repository->findWhere([
    //Default Condition =
    'state_id'=>'10',
    'country_id'=>'15',

    //Custom Condition
    ['columnName1','>','10'],

    //DATE, DAY, MONTH, YEAR
    ['columnName2','DATE','2021-07-02'], //whereDate
    ['columnName3','DATE >=','2021-07-02'], //whereDate with operator

    ['columnName4','IN',['value1','value2']], //whereIn
    ['columnName5','NOTIN',['value1','value2']], //whereNotIn
    ['columnName6','EXIST',''], //whereExists
    
    //HAS, HASMORPH, DOESNTHAVE, DOESNTHAVEMORPH
    ['columnName7','HAS',function($query){}], //whereHas

    //BETWEEN, BETWEENCOLUMNS, NOTBETWEEN, NOTBETWEENCOLUMNS
    ['columnName8','BETWEEN',[10, 100]], //whereBetween
]);

Find by result by multiple values in one field

$posts = $this->repository->findWhereIn('id', [1,2,3,4,5]);

Find by result by excluding multiple values in one field

$posts = $this->repository->findWhereNotIn('id', [6,7,8,9,10]);

Find all using custom scope

$posts = $this->repository->scopeQuery(function($query){
    return $query->orderBy('sort_order','asc');
})->all();

Create new entry in Repository

$post = $this->repository->create( Input::all() );

Update entry in Repository

$post = $this->repository->update( Input::all(), $id );

Delete entry in Repository

$this->repository->delete($id)

Delete entry in Repository by multiple fields

$this->repository->deleteWhere([
    //Default Condition =
    'state_id'=>'10',
    'country_id'=>'15',
])

Create a Criteria

Using the command

php artisan make:criteria MyCriteria

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.

use Prettus\Repository\Contracts\RepositoryInterface;
use Prettus\Repository\Contracts\CriteriaInterface;

class MyCriteria implements CriteriaInterface {

    public function apply($model, RepositoryInterface $repository)
    {
        $model = $model->where('user_id','=', Auth::user()->id );
        return $model;
    }
}

Using the Criteria in a Controller

namespace App\Http\Controllers;

use App\PostRepository;

class PostsController extends BaseController {

    /**
     * @var PostRepository
     */
    protected $repository;

    public function __construct(PostRepository $repository){
        $this->repository = $repository;
    }


    public function index()
    {
        $this->repository->pushCriteria(new MyCriteria1());
        $this->repository->pushCriteria(MyCriteria2::class);
        $posts = $this->repository->all();
		...
    }

}

Getting results from Criteria

$posts = $this->repository->getByCriteria(new MyCriteria());

Setting the default Criteria in Repository

use Prettus\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    public function boot(){
        $this->pushCriteria(new MyCriteria());
        // or
        $this->pushCriteria(AnotherCriteria::class);
        ...
    }

    function model(){
       return "App\\Post";
    }
}

Skip criteria defined in the repository

Use skipCriteria before any other chaining method

$posts = $this->repository->skipCriteria()->all();

Popping criteria

Use popCriteria to remove a criteria

$this->repository->popCriteria(new Criteria1());
// or
$this->repository->popCriteria(Criteria1::class);

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

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;


class PostRepository extends BaseRepository {

	/**
     * @var array
     */
    protected $fieldSearchable = [
        'name',
        'email'
    ];

    public function boot(){
        $this->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria'));
        ...
    }

    function model(){
       return "App\\Post";
    }
}

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.

protected $fieldSearchable = [
	'name',
	'email',
	'product.name'
];

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

'condition' ]; ">
protected $fieldSearchable = [
	'name'=>'like',
	'email', // Default Condition "="
	'your_field'=>'condition'
];

Enabling in your Controller

	public function index()
    {
        $this->repository->pushCriteria(app('Prettus\Repository\Criteria\RequestCriteria'));
        $posts = $this->repository->all();
		...
    }

Example the Criteria

Request all data without filter by request

http://prettus.local/users

[
    {
        "id": 1,
        "name": "John Doe",
        "email": "[email protected]",
        "created_at": "-0001-11-30 00:00:00",
        "updated_at": "-0001-11-30 00:00:00"
    },
    {
        "id": 2,
        "name": "Lorem Ipsum",
        "email": "[email protected]",
        "created_at": "-0001-11-30 00:00:00",
        "updated_at": "-0001-11-30 00:00:00"
    },
    {
        "id": 3,
        "name": "Laravel",
        "email": "[email protected]",
        "created_at": "-0001-11-30 00:00:00",
        "updated_at": "-0001-11-30 00:00:00"
    }
]

Conducting research in the repository

http://prettus.local/users?search=John%20Doe

or

http://prettus.local/users?search=John&searchFields=name:like

or

http://prettus.local/[email protected]&searchFields=email:=

or

http://prettus.local/users?search=name:John Doe;email:[email protected]

or

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

[
    {
        "id": 1,
        "name": "John Doe",
        "email": "[email protected]",
        "created_at": "-0001-11-30 00:00:00",
        "updated_at": "-0001-11-30 00:00:00"
    }
]

You can use params "search" without full params "searchFields".

http://prettus.local/users?search=id:2;age:17;email:[email protected]&searchFields='id':=

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

The above example will execute the following query:

SELECT * FROM users WHERE age = 17 OR email = '[email protected]';

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

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

Filtering fields

http://prettus.local/users?filter=id;name

[
    {
        "id": 1,
        "name": "John Doe"
    },
    {
        "id": 2,
        "name": "Lorem Ipsum"
    },
    {
        "id": 3,
        "name": "Laravel"
    }
]

Sorting the results

http://prettus.local/users?filter=id;name&orderBy=id&sortedBy=desc

[
    {
        "id": 3,
        "name": "Laravel"
    },
    {
        "id": 2,
        "name": "Lorem Ipsum"
    },
    {
        "id": 1,
        "name": "John Doe"
    }
]

Sorting through related tables

http://prettus.local/users?orderBy=posts|title&sortedBy=desc

Query will have something like this

...
INNER JOIN posts ON users.post_id = posts.id
...
ORDER BY title
...

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

Query will have something like this

...
INNER JOIN posts ON users.custom_id = posts.id
...
ORDER BY posts.title
...

http://prettus.local/users?orderBy=posts:custom_id,other_id|posts.title&sortedBy=desc

Query will have something like this

...
INNER JOIN posts ON users.custom_id = posts.other_id
...
ORDER BY posts.title
...

Sorting multiple columns same sortedBy

http://prettus.local/users?orderBy=name;created_at&sortedBy=desc

Result will have something like this

   [
       {
           "id": 1,
           "name": "Laravel",
           "created_at": "-0001-11-29 00:00:00"
       },
       {
           "id": 3,
           "name": "Laravel",
           "created_at": "-0001-11-28 00:00:00"
       },
       {
           "id": 2,
           "name": "John Doe",
           "created_at": "-0001-11-30 00:00:00"
       }
   ]

Sorting multiple columns difference sortedBy

http://prettus.local/users?orderBy=name;created_at&sortedBy=desc;asc

Result will have something like this

   [
       {
           "id": 3,
           "name": "Laravel",
           "created_at": "-0001-11-28 00:00:00"
       },
       {
           "id": 1,
           "name": "Laravel",
           "created_at": "-0001-11-29 00:00:00"
       },
       {
           "id": 2,
           "name": "John Doe",
           "created_at": "-0001-11-30 00:00:00"
       }
   ]

Add relationship

http://prettus.local/users?with=groups

Between filter

http://prettus.local/product?search=price:100,500&searchFields=price:between

Result will have something like this

   [
       {
           "id": 3,
           "price": "150",
           "created_at": "-0001-11-28 00:00:00"
       },
       {
           "id": 1,
           "price": "300",
           "created_at": "-0001-11-29 00:00:00"
       },
       {
           "id": 2,
           "price": "450",
           "created_at": "-0001-11-30 00:00:00"
       }
   ]

WhereIn filter

http://prettus.local/product?search=price:300,500&searchFields=price:in

Result will have something like this

   [
       {
           "id": 1,
           "price": "300",
           "created_at": "-0001-11-29 00:00:00"
       }
   ]

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.

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Contracts\CacheableInterface;
use Prettus\Repository\Traits\CacheableRepository;

class PostRepository extends BaseRepository implements CacheableInterface {

    use CacheableRepository;

    ...
}

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

'cache'=>[
    //Enable or disable cache repositories
    'enabled'   => true,

    //Lifetime of cache
    'minutes'   => 30,

    //Repository Cache, implementation Illuminate\Contracts\Cache\Repository
    'repository'=> 'cache',

    //Sets clearing the cache
    'clean'     => [
        //Enable, disable clearing the cache on changes
        'enabled' => true,

        'on' => [
            //Enable, disable clearing the cache when you create an item
            'create'=>true,

            //Enable, disable clearing the cache when upgrading an item
            'update'=>true,

            //Enable, disable clearing the cache when you delete an item
            'delete'=>true,
        ]
    ],
    'params' => [
        //Request parameter that will be used to bypass the cache repository
        'skipCache'=>'skipCache'
    ],
    'allowed'=>[
        //Allow caching only for some methods
        'only'  =>null,

        //Allow caching for all available methods, except
        'except'=>null
    ],
],

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

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Contracts\CacheableInterface;
use Prettus\Repository\Traits\CacheableRepository;

class PostRepository extends BaseRepository implements CacheableInterface {

    // Setting the lifetime of the cache to a repository specifically
    protected $cacheMinutes = 90;

    protected $cacheOnly = ['all', ...];
    //or
    protected $cacheExcept = ['find', ...];

    use CacheableRepository;

    ...
}

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

Validators

Requires prettus/laravel-validator. composer require prettus/laravel-validator

Easy validation with prettus/laravel-validator

For more details click here

Using a Validator Class

Create a Validator

In the example below, we define some rules for both creation and edition

use \Prettus\Validator\LaravelValidator;

class PostValidator extends LaravelValidator {

    protected $rules = [
        'title' => 'required',
        'text'  => 'min:3',
        'author'=> 'required'
    ];

}

To define specific rules, proceed as shown below:

use \Prettus\Validator\Contracts\ValidatorInterface;
use \Prettus\Validator\LaravelValidator;

class PostValidator extends LaravelValidator {

    protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'title' => 'required',
            'text'  => 'min:3',
            'author'=> 'required'
        ],
        ValidatorInterface::RULE_UPDATE => [
            'title' => 'required'
        ]
   ];

}
Enabling Validator in your Repository
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;

class PostRepository extends BaseRepository {

    /**
     * Specify Model class name
     *
     * @return mixed
     */
    function model(){
       return "App\\Post";
    }

    /**
     * Specify Validator class name
     *
     * @return mixed
     */
    public function validator()
    {
        return "App\\PostValidator";
    }
}

Defining rules in the repository

Alternatively, instead of using a class to define its validation rules, you can set your rules directly into the rules repository property, it will have the same effect as a Validation class.

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use Prettus\Validator\Contracts\ValidatorInterface;

class PostRepository extends BaseRepository {

    /**
     * Specify Validator Rules
     * @var array
     */
     protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'title' => 'required',
            'text'  => 'min:3',
            'author'=> 'required'
        ],
        ValidatorInterface::RULE_UPDATE => [
            'title' => 'required'
        ]
   ];

    /**
     * Specify Model class name
     *
     * @return mixed
     */
    function model(){
       return "App\\Post";
    }

}

Validation is now ready. In case of a failure an exception will be given of the type: Prettus\Validator\Exceptions\ValidatorException

Presenters

Presenters function as a wrapper and renderer for objects.

Fractal Presenter

Requires Fractal. composer require league/fractal

There are two ways to implement the Presenter, the first is creating a TransformerAbstract and set it using your Presenter class as described in the Create a Transformer Class.

The second way is to make your model implement the Transformable interface, and use the default Presenter ModelFractarPresenter, this will have the same effect.

Transformer Class
Create a Transformer using the command
php artisan make:transformer Post

This will generate the class beneath.

Create a Transformer Class
use League\Fractal\TransformerAbstract;

class PostTransformer extends TransformerAbstract
{
    public function transform(\Post $post)
    {
        return [
            'id'      => (int) $post->id,
            'title'   => $post->title,
            'content' => $post->content
        ];
    }
}
Create a Presenter using the command
php artisan make:presenter Post

The command will prompt you for creating a Transformer too if you haven't already.

Create a Presenter
use Prettus\Repository\Presenter\FractalPresenter;

class PostPresenter extends FractalPresenter {

    /**
     * Prepare data to present
     *
     * @return \League\Fractal\TransformerAbstract
     */
    public function getTransformer()
    {
        return new PostTransformer();
    }
}
Enabling in your Repository
use Prettus\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    ...

    public function presenter()
    {
        return "App\\Presenter\\PostPresenter";
    }
}

Or enable it in your controller with

$this->repository->setPresenter("App\\Presenter\\PostPresenter");
Using the presenter after from the Model

If you recorded a presenter and sometime used the skipPresenter() method or simply you do not want your result is not changed automatically by the presenter. You can implement Presentable interface on your model so you will be able to present your model at any time. See below:

In your model, implement the interface Prettus\Repository\Contracts\Presentable and Prettus\Repository\Traits\PresentableTrait

namespace App;

use Prettus\Repository\Contracts\Presentable;
use Prettus\Repository\Traits\PresentableTrait;

class Post extends Eloquent implements Presentable {

    use PresentableTrait;

    protected $fillable = [
        'title',
        'author',
        ...
     ];

     ...
}

There, now you can submit your Model individually, See an example:

find(1); print_r( $post ); //It produces an output as array ... //Skip presenter and bringing the original result of the Model $post = $repository->skipPresenter()->find(1); print_r( $post ); //It produces an output as a Model object print_r( $post->presenter() ); //It produces an output as array ">
$repository = app('App\PostRepository');
$repository->setPresenter("Prettus\\Repository\\Presenter\\ModelFractalPresenter");

//Getting the result transformed by the presenter directly in the search
$post = $repository->find(1);

print_r( $post ); //It produces an output as array

...

//Skip presenter and bringing the original result of the Model
$post = $repository->skipPresenter()->find(1);

print_r( $post ); //It produces an output as a Model object
print_r( $post->presenter() ); //It produces an output as array

You can skip the presenter at every visit and use it on demand directly into the model, for it set the $skipPresenter attribute to true in your repository:

use Prettus\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    /**
    * @var bool
    */
    protected $skipPresenter = true;

    public function presenter()
    {
        return "App\\Presenter\\PostPresenter";
    }
}
Model Class
Implement Interface
namespace App;

use Prettus\Repository\Contracts\Transformable;

class Post extends Eloquent implements Transformable {
     ...
     /**
      * @return array
      */
     public function transform()
     {
         return [
             'id'      => (int) $this->id,
             'title'   => $this->title,
             'content' => $this->content
         ];
     }
}
Enabling in your Repository

Prettus\Repository\Presenter\ModelFractalPresenter is a Presenter default for Models implementing Transformable

use Prettus\Repository\Eloquent\BaseRepository;

class PostRepository extends BaseRepository {

    ...

    public function presenter()
    {
        return "Prettus\\Repository\\Presenter\\ModelFractalPresenter";
    }
}

Or enable it in your controller with

$this->repository->setPresenter("Prettus\\Repository\\Presenter\\ModelFractalPresenter");

Skip Presenter defined in the repository

Use skipPresenter before any other chaining method

$posts = $this->repository->skipPresenter()->all();

or

$this->repository->skipPresenter();

$posts = $this->repository->all();
Comments
  • Add more commands?

    Add more commands?

    Adding more commands

    • [x] make:transformer (merged #55)
    • [x] make:presenter (merged #57)
    • [x] make:entity - (merged #58)

    the make:entity command would generate the Repository, the Transformer, the Presenter and the Validator for that entity.

    opened by ghost 18
  • Laravel 7.0 support

    Laravel 7.0 support

    • bump illuminate package dependency constraint to version ~7.0
    • the 'addVisible' method has been removed in laravel 7. The 'makeVisible' method should be used instead
    
    opened by ammonkc 17
  • BaseRepository::sync

    BaseRepository::sync

    Bug? No $id attribute

        /**
         * Sync relations
         *
         * @param $id
         * @param $relation
         * @param array $attributes
         * @return $this
         */
        public function sync($relation, $attributes)
    
    opened by schursin 17
  • make:entity not creating controller in Laravel 5.5

    make:entity not creating controller in Laravel 5.5

    Hello,

    I'm using Laravel 5.5.3 with l5-repository v 2.6.22 - fresh install of both.

    My issue is that the make:entity command is not producing a Controller. All other files are created as expected and the path for controllers is set appropriately.

    opened by berzley 16
  • Generator broken for Laravel 5.4

    Generator broken for Laravel 5.4

    Generator throws error.

    php artisan make:entity Blah

      [Symfony\Component\Debug\Exception\FatalErrorException]
      Trait 'Illuminate\Console\AppNamespaceDetectorTrait' not found
    

    Fixed in #331

    opened by hayeah 15
  • using repository create method fails when attribute is marked as hidden & fillable

    using repository create method fails when attribute is marked as hidden & fillable

    I have a user object that I am trying to create using

    $this->userRepository->create([
        'name' => 'user1',
    ]);
    

    and the User object has the password field marked as hidden, but also fillable. but once I use the create method, it fails saying that the password field is required even though it passes validation before being passed to the repository method.

    opened by ericp1337 11
  • Criteria & Cache ?

    Criteria & Cache ?

    Hello,

    It seems that the criteria are not working with the cache.

    E.g :

    // cache the records for the all() method
    $records = $modelRepository->all();
    
    // Could be withTrashed or whereHas or custom where criteria
    $modelRepository->pushCriteria(\Namespace\CustomCriteria($params)); 
    // Ignore the criteria and fetch the records from the cache
    $records = $modelRepository->all(); 
    

    We could use the getByCriteria() method but we can't use this method with multiple criteria.

    Thanks

    opened by DarKDinDoN 11
  • Find by multiple fields?

    Find by multiple fields?

    Either I don't see the method, or the type hinting for the return is incorrect, how would one do the equivalent of whereX(1)->where('y','>',150) or something similar?

    opened by michaeljhopkins 11
  • How to add new methods?

    How to add new methods?

    Hi, I have a questions, how to add a new method (What file modify?) For example:

    public function deleteMultipleById(array $ids)
    {
        return $this->model->destroy($ids);
    }
    

    Where add the code? vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php or Repositories/CustomRepository.php

    opened by ssheduardo 9
  • Searching by multiple search fields

    Searching by multiple search fields

    Hi All

    First off - Thank you for this package. I struggled for a while implementing what I wanted: Fractal, URL query searches, and some way to use existing models in my L5 app. This puts all those things together in a lovely package.

    I'm struggling with one thing, which I think shouldn't be too hard. I simply want to be able to use URL query params to filter my REST api results. My URL should look like this:

    my-app.local/api/v1/temp?page=2&search=tempType:a;state:FL
    

    I have the fields referenced there listed as searchable in the repository:

    /**
         * @var array
         */
        protected $fieldSearchable = [
            'firstName'    => 'like',
            'lastName'     => 'like',
            'address'      => 'like',
            'city'         => 'like',
            'state'        => '=',
            'zip'          => '=',
            'phone'        => '=',
            'email'        => 'like',
            'recruiter'    => '=',
            'tempType'     => '='
        ];
    

    The first value is actually used properly. If I do:

    my-app.local/api/v1/temp?page=2&search=tempType:a
    

    I'll get the correct results. And If I use the other field, i also get the correct results:

    my-app.local/api/v1/temp?page=2&search=tempType:a
    

    Combining them; the first field is used in the filter but the second is not.

    Testing: With this URL:

    my-app.local/api/v1/temp?page=2&search=tempType:a;state:FL
    

    I looked into RequestCriteria: https://github.com/andersao/l5-repository/blob/master/src/Prettus/Repository/Criteria/RequestCriteria.php#L52

    I threw a bunch of var-dumps in there:

    var_dump($searchFields);
    var_dump($search);
    var_dump($searchData);
    

    And it seems to be properly splitting the values out:

    $searchFields:

    array (size=2)
      'state' => string 'fl' (length=2)
      'tempType' => string 'a' (length=1)
    

    $fields

    array (size=10)
      'firstName' => string 'like' (length=4)
      'lastName' => string 'like' (length=4)
      'address' => string 'like' (length=4)
      'city' => string 'like' (length=4)
      'state' => string '=' (length=1)
      'zip' => string '=' (length=1)
      'phone' => string '=' (length=1)
      'email' => string 'like' (length=4)
      'recruiter' => string '=' (length=1)
      'tempType' => string '=' (length=1)
    

    I even checked to make sure it wasn't hitting the null value check:

    $value

    string 'fl' (length=2)
    string 'a' (length=2)
    

    As far as i can tell, I'm doing everything close to correct. But maybe I'm missing something. I'm sure its probably around the where statement that is getting generated or something along those lines. Any ideas on how I can do this would be super helpful.

    Thanks all Chad

    opened by drmmr763 9
  • installation error in laravel 7.0

    installation error in laravel 7.0

    iluminnate/validation still gave error after the new merge, error:

    Problem 1 - Installation request for prettus/l5-repository dev-master -> satisfiable by prettus/l5-repository[dev-master]. - Conclusion: remove laravel/framework v7.0.5 - Conclusion: don't install laravel/framework v7.0.5 - prettus/l5-repository dev-master requires prettus/laravel-validation ~1.1|~1.2 -> satisfiable by prettus/laravel-validation[1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1. 4, 1.1.5, 1.2.0]. - prettus/laravel-validation 1.1.0 requires illuminate/validation ~5.0 -> satisfiable by illuminate/validation[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4 .x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5. 2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v 5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6 .12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6. 3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7. 10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8. 11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33 , v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.1.1 requires illuminate/validation ~5.0 -> satisfiable by illuminate/validation[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4 .x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5. 2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v 5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6 .12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6. 3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7. 10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8. 11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33 , v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.1.2 requires illuminate/validation ~5.0 -> satisfiable by illuminate/validation[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4 .x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5. 2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v 5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6 .12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6. 3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7. 10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8. 11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33 , v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.1.3 requires illuminate/validation ~5.0 -> satisfiable by illuminate/validation[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4 .x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5.1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28, v5. 2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v 5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6 .12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6. 3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7. 10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8. 11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33 , v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.1.4 requires illuminate/validation ~5.0|~5.1 -> satisfiable by illuminate/validation[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev , 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, v5.0.26, v5.0.28, v5.0.33, v5.0.4, v5.1.1, v5.1.13, v5. 1.16, v5.1.2, v5.1.20, v5.1.22, v5.1.25, v5.1.28, v5.1.30, v5.1.31, v5.1.41, v5.1.6, v5.1.8, v5.2.0, v5.2.19, v5.2.21, v5.2.24, v5.2.25, v5.2.26, v5.2.27, v5.2.28 , v5.2.31, v5.2.32, v5.2.37, v5.2.43, v5.2.45, v5.2.6, v5.2.7, v5.3.0, v5.3.16, v5.3.23, v5.3.4, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5 .0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5 .8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.1.5 requires illuminate/validation ~5.4 -> satisfiable by illuminate/validation[5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18 , 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5.5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6.17, v5.6.19, v 5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34, v5.6.35, v5. 6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21, v5.7.22, v5. 7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5 .8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9]. - prettus/laravel-validation 1.2.0 requires illuminate/validation ~5.4|^6.0 -> satisfiable by illuminate/validation[5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5 .7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, 6.x-dev, v5.4.0, v5.4.13, v5.4.17, v5.4.19, v5.4.27, v5.4.36, v5.4.9, v5.5.0, v5.5.16, v5.5.17, v5.5.2, v5.5.28, v5.5.33, v5. 5.34, v5.5.35, v5.5.36, v5.5.37, v5.5.39, v5.5.40, v5.5.41, v5.5.43, v5.5.44, v5.6.0, v5.6.1, v5.6.10, v5.6.11, v5.6.12, v5.6.13, v5.6.14, v5.6.15, v5.6.16, v5.6. 17, v5.6.19, v5.6.2, v5.6.20, v5.6.21, v5.6.22, v5.6.23, v5.6.24, v5.6.25, v5.6.26, v5.6.27, v5.6.28, v5.6.29, v5.6.3, v5.6.30, v5.6.31, v5.6.32, v5.6.33, v5.6.34 , v5.6.35, v5.6.36, v5.6.37, v5.6.38, v5.6.39, v5.6.4, v5.6.5, v5.6.6, v5.6.7, v5.6.8, v5.6.9, v5.7.0, v5.7.1, v5.7.10, v5.7.11, v5.7.15, v5.7.2, v5.7.20, v5.7.21 , v5.7.22, v5.7.23, v5.7.26, v5.7.27, v5.7.28, v5.7.3, v5.7.4, v5.7.5, v5.7.6, v5.7.7, v5.7.8, v5.7.9, v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.1 8, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v 5.8.9, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4, v6.1.0, v6.10.0, v6.11.0, v6.12.0, v6.13.0, v6.13.1, v6.14.0, v6.15.0, v6.15.1, v6.16.0, v6.17.0, v6.17.1, v6.18.0, v6.18.1, v6.2.0, v6.3.0, v6.4.1, v6.5.0, v6.5.1, v6.5.2, v6.6.0, v6.6.1, v6.6.2, v6.7.0, v6.8.0]. - don't install illuminate/validation 5.0.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.1.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.2.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.3.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.4.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.5.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.6.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.7.17|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.7.18|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.7.19|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.7.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation 5.8.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.22|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.25|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.26|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.33|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.0.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.13|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.16|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.20|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.22|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.25|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.30|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.31|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.41|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.6|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.1.8|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.19|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.21|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.24|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.25|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.26|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.27|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.31|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.32|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.37|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.43|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.45|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.6|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.2.7|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.3.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.3.16|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.3.23|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.3.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.13|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.17|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.19|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.27|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.36|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.4.9|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.16|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.17|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.33|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.34|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.35|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.36|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.37|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.39|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.40|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.41|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.43|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.5.44|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.10|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.11|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.12|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.13|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.14|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.15|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.16|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.17|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.19|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.20|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.21|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.22|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.23|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.24|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.25|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.26|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.27|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.29|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.3|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.30|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.31|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.32|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.33|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.34|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.35|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.36|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.37|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.38|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.39|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.5|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.6|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.7|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.8|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.6.9|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.10|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.11|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.15|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.20|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.21|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.22|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.23|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.26|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.27|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.3|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.5|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.6|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.7|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.8|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.7.9|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.11|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.12|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.14|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.15|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.17|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.18|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.19|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.20|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.22|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.24|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.27|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.28|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.29|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.3|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.30|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.31|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.32|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.33|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.34|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.35|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.36|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.8|don't install laravel/framework v7.0.5 - don't install illuminate/validation v5.8.9|don't install laravel/framework v7.0.5 - don't install illuminate/validation 6.x-dev|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.0.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.0.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.0.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.0.3|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.0.4|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.1.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.10.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.11.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.12.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.13.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.13.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.14.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.15.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.15.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.16.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.17.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.17.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.18.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.18.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.2.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.3.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.4.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.5.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.5.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.5.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.6.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.6.1|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.6.2|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.7.0|don't install laravel/framework v7.0.5 - don't install illuminate/validation v6.8.0|don't install laravel/framework v7.0.5 - Installation request for laravel/framework (locked at v7.0.5, required as ^7.0) -> satisfiable by laravel/framework[v7.0.5].

    opened by lucasantoniooficial 8
  • depricated error on request citeria

    depricated error on request citeria

    hi i get this error on laravel log files:

    local.WARNING: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in my project pach/vendor/prettus/l5-repository/src/Prettus/Repository/Criteria/RequestCriteria.php on line 58

    i think need to update this file

    opened by Rasoul-Karimi 0
  • Target class [] does not exist

    Target class [] does not exist

    yesterday this problem started to appear in my code without me having changed absolutely anything, I just used a composer update. And the logs says it starts on "makeModel()" of this package:

    [2022-03-23 14:37:54] local.ERROR: Target class [] does not exist. {"exception":"[object] (Illuminate\\Contracts\\Container\\BindingResolutionException(code: 0): Target class [] does not exist. at /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php:875) [stacktrace] #0 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\Container->build() #1 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\\Container\\Container->resolve() #2 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve() #3 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\\Container\\Container->make() #4 /var/www/html/socialhub.shippings/vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php(192): Illuminate\\Foundation\\Application->make() #5 /var/www/html/socialhub.shippings/vendor/prettus/l5-repository/src/Prettus/Repository/Eloquent/BaseRepository.php(99): Prettus\\Repository\\Eloquent\\BaseRepository->makeModel() #6 [internal function]: Prettus\\Repository\\Eloquent\\BaseRepository->__construct() #7 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(917): ReflectionClass->newInstanceArgs() #8 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\Container->build() #9 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\\Container\\Container->resolve() #10 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve() #11 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\\Container\\Container->make() #12 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(1027): Illuminate\\Foundation\\Application->make() #13 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(947): Illuminate\\Container\\Container->resolveClass() #14 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(908): Illuminate\\Container\\Container->resolveDependencies() #15 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(754): Illuminate\\Container\\Container->build() #16 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\\Container\\Container->resolve() #17 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\\Foundation\\Application->resolve() #18 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\\Container\\Container->make() #19 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Routing/Route.php(275): Illuminate\\Foundation\\Application->make() #20 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Routing/Route.php(1049): Illuminate\\Routing\\Route->getController() #21 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Routing/Route.php(1010): Illuminate\\Routing\\Route->controllerMiddleware() #22 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): Illuminate\\Routing\\Route->gatherMiddleware() #23 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php(175): Illuminate\\Routing\\Router->gatherRouteMiddleware() #24 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php(119): Illuminate\\Foundation\\Console\\RouteListCommand->getMiddleware() #25 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php(91): Illuminate\\Foundation\\Console\\RouteListCommand->getRouteInformation() #26 [internal function]: Illuminate\\Foundation\\Console\\RouteListCommand->Illuminate\\Foundation\\Console\\{closure}() #27 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Collections/Collection.php(640): array_map() #28 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php(92): Illuminate\\Support\\Collection->map() #29 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/RouteListCommand.php(76): Illuminate\\Foundation\\Console\\RouteListCommand->getRoutes() #30 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\\Foundation\\Console\\RouteListCommand->handle() #31 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}() #32 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\\Container\\Util::unwrapIfClosure() #33 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\\Container\\BoundMethod::callBoundMethod() #34 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Container/Container.php(651): Illuminate\\Container\\BoundMethod::call() #35 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\\Container\\Container->call() #36 /var/www/html/socialhub.shippings/vendor/symfony/console/Command/Command.php(299): Illuminate\\Console\\Command->execute() #37 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run() #38 /var/www/html/socialhub.shippings/vendor/symfony/console/Application.php(978): Illuminate\\Console\\Command->run() #39 /var/www/html/socialhub.shippings/vendor/symfony/console/Application.php(295): Symfony\\Component\\Console\\Application->doRunCommand() #40 /var/www/html/socialhub.shippings/vendor/symfony/console/Application.php(167): Symfony\\Component\\Console\\Application->doRun() #41 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Console/Application.php(92): Symfony\\Component\\Console\\Application->run() #42 /var/www/html/socialhub.shippings/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\\Console\\Application->run() #43 /var/www/html/socialhub.shippings/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle() #44 {main}

    opened by Iscrimou 0
  • RequestCriteria supports for Morph relationship

    RequestCriteria supports for Morph relationship

    Problem

    Query for morphTo relationship will get an exception of "Please use whereHasMorph for morph relationship" error.

    Idea of change

    Add new condition for a bit more complex setups as array.

    // Example, the data relationship has different morph types for purpose, and we can specify a condition as array for those needed parameters. 
    
    public ProductRepository extends BaseRepository {
        protected $fieldSearchable = [
            'product_name' => 'like',
            'data.category' => [
                'relationType' => 'morph',
                'condition' => '=',
                'types' => [Turnkey::class, Pcba::class, Pcb::class, MouldTooling::class, Accessory::class],
            ],
        ];
    
    // Changed RequestCriteria class
    
    // patch for morph relationship query
    if (is_array($condition)) {
       $types = $condition['types'];
       $relationType = $condition['relationType'];
       $condition = $condition['condition'];
    }
    
    $condition = trim(strtolower($condition));
    
    if(!is_null($relation)) {
        $callback = function($query) use($field,$condition,$value) {
           if($condition === 'in'){
               $query->whereIn($field,$value);
          }elseif($condition === 'between'){
             $query->whereBetween($field,$value);
          }else{
             $query->where($field,$condition,$value);
         }
       };
    
      // patch example for morph relation
       if (!is_null($relationType) && $relationType == 'morph') {
          $query->whereHasMorph($relation, $types, $callback);
          // $query->orWhereHasMorph($relation, $types, $callback); // when it shall be OR..
       } else {
           $query->whereHas($relation, $callback);
       }
    }
    

    Commenting

    The idea code is just an example for describing the idea, this issue could be used to discuss if any potential problem of this change and recommendations.

    opened by oh-bala 0
Releases(2.8.0)
Owner
Anderson Andrade
AWS Solutions Architect
Anderson Andrade
An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality.

Support An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality. Ins

Ian Olson 3 Apr 14, 2021
Laravel 5.* package to easily introduce a transformation layer for your data

Laraformer Laraformer is a laravel 5.* package that lets you easily introduce a transformation layer for your data. Laraformer (originated from Larave

Kamran Ahmed 30 Oct 19, 2022
An abstraction layer to get data from array or a file with dot-notation

Alex Unruh - Config This library is based on the Laravel config concept. It values performance and was built on top of the library Dflydev Dot Access

Alexandre Odair 3 May 20, 2022
This package provides extended support for our spatie/enum package in Laravel.

Laravel support for spatie/enum This package provides extended support for our spatie/enum package in Laravel. Installation You can install the packag

Spatie 264 Dec 23, 2022
Output complex, flexible, AJAX/RESTful data structures.

Fractal Fractal provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with J

The League of Extraordinary Packages 3.5k Dec 26, 2022
A Laravel package making a diagram of your models, relations and the ability to build them with it

Laravel Schematics This package allows you to make multiple diagrams of your Eloquent models and their relations. It will help building them providing

Maarten Tolhuijs 1.4k Dec 31, 2022
This package provides convenient methods for making token code, sending and verifying mobile phone verification requests.

Laravel Mobile Verification Introduction Many web applications require users to verify their mobile phone numbers before using the application. Rather

M.Fouladgar 347 Dec 25, 2022
A simple artisanal command framework for creating service layer classes

Introdução Este projeto tem como objetivo fornecer alguns comandos adicionais à interface de linha de comando do Laravel para manipular a estrutura da

Eliezer Alves 15 Feb 2, 2022
An abstraction layer for easily implementing industry-standard caching strategies

Laravel Model Repository This package provides an abstraction layer for easily implementing industry-standard caching strategies with Eloquent models.

null 44 Dec 31, 2022
A quiz application with laravel 8, spatie permissions, livewire, jetstream, chartjs, tailwindcss and more!

Todo Currently busy with some other important things, will definately would like to imporove the app with 1. Multiple choices selection and mapping to

Baig 67 Nov 21, 2022
Laravel Boilerplate provides a very flexible and extensible way of building your custom Laravel applications.

Laravel Boilerplate Project Laravel Boilerplate provides a very flexible and extensible way of building your custom Laravel applications. Table of Con

Labs64 848 Dec 28, 2022
Entrust is a succinct and flexible way to add Role-based Permissions to Laravel 5.

ENTRUST (Laravel 5 Package) Entrust is a succinct and flexible way to add Role-based Permissions to Laravel 5. If you are looking for the Laravel 4 ve

Zizaco 6.1k Dec 31, 2022
🔔 Flasher is a powerful and flexible flash notification system for PHP, Laravel, Symfony

A powerful and flexible flash notifications system for PHP, Laravel, Symfony ?? PHP Flasher helps you to add flash notifications to your PHP projects.

PHP Flasher 158 Jan 4, 2023
A flexible, seamless and easy to use multitenancy solution for Laravel

Main: Develop: Tenanted Laravel A flexible, seamless and easy to use multitenancy solution for Laravel This package is currently under development. Ch

Tenanted Laravel 12 May 29, 2023
Laravel Countries is a bundle for Laravel, providing Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries.

Laravel Countries Laravel Countries is a bundle for Laravel, providing Almost ISO 3166_2, 3166_3, currency, Capital and more for all countries. Please

Christoph Kempen 695 Dec 30, 2022
Laravel Livewire (TALL-stack) form generator with realtime validation, file uploads, array fields, blade form input components and more.

TALL-stack form generator Laravel Livewire, Tailwind forms with auto-generated views. Support Contributions Features This is not an admin panel genera

TinaH 622 Jan 2, 2023
a Laravel package help you to execute more effective databases queries.

Laravel Query Helper Laravel Query Helper was developed for laravel 7.2+ to help you optimizing sql queries, this package will contain all advanced sq

karam mustafa 9 Jul 26, 2022
Links statistics & link tracking for laravel 5, It tracks down browsers, operating systems, languages and more

Links Links statistics for laravel 5 Table Of Contents Installation Configuration Usage Installation To install charts use composer Download composer

Erik C. Forés 52 Jul 31, 2021
Manage your staff from one place. Featuring Staff leave management 🏖, payslips 💵 generation & emailing, messaging 📨and more 🛠! Built with ❤️ with Laravel

Staff Management System This little buddy can help you manage your staff database! Built with ?? with Laravel #FEATURES 1 Staff management/ database S

Ezekiel Oladejo 45 Jan 3, 2023