LARS abstract the data layer, making it easy to maintain.
You can install the package via composer:
composer require omatech/larsCreate your own repository class extending BaseRepository class, use the model function to set the eloquent model for the repository.
class Repository extends BaseRepository
{
    public function model() : String
    {
        return Model::class;
    }
}Now you can create your own function using query builder easily.
public function method()
{
    return $this->query()
                ->get();
}Create a criteria implementing the interface CriteriaInterface. With the apply function you can filter by your own criteria.
public class Criteria implements CriteriaInterface
{
    public function apply(Builder $q) : Builder
    {
        return $q->where('role', 'admin');
    }
}public function method()
{
    return $this->pushCriteria(new FooCriteria)
                ->query()
                ->get();
}public function method()
{
    return $this->getCriterias();
}public function method()
{
    return $this->pushCriteria(new FooCriteria)
                ->popCriteria(new FooCriteria)
                ->query()
                ->get();
}public function method()
{
    return $this->pushCriteria(new FooCriteria)
                ->pushCriteria(new BarCriteria)
                ->resetCriteria()
                ->query()
                ->get();
}It is possible to apply a criteria to all methods using the construct method of the repository.
public function __construct()
{
    $this->pushCriteria(new FooCriteria);
}Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email cbohollo@omatech.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.