2017 © Pedro Peláez
 

library repoist

Laravel 5.6 repository generator.

image

ozankurt/repoist

Laravel 5.6 repository generator.

  • Saturday, March 10, 2018
  • by OzanKurt
  • Repository
  • 6 Watchers
  • 81 Stars
  • 8,526 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 25 Forks
  • 2 Open issues
  • 10 Versions
  • 6 % Grown

The README.md

Repoist

Laravel repository generator for 5.2+ versions, (*1)

Usage

Step 1: Install Through Composer

composer require ozankurt/repoist

Step 2: Publish and edit the configurations

In Laravel: Run php artisan vendor:publish --tag=repoist-config from the console to configure the Repoist according to your needs., (*2)

Step 3: Run Artisan!

You're all set. Run php artisan from the console, and you'll see the new commands., (*3)

For Lumen

In bootstrap\app.php enable Facades and Eloquent, also enable the configuration file., (*4)

$app->withFacades();
$app->withEloquent();

$app->configure('repoist');

In the Register service providers section add:, (*5)

$app->register(Kurt\Repoist\RepoistServiceProvider::class);

Examples

Repository

php artisan make:repository Task

Will output:, (*6)

  • app/Contracts/Task/TaskRepository.php (contract)
  • app/Repositories/Eloquent/EloquentTaskRepository.php
  • app/Task.php (if needed)

Criterion

php artisan make:criterion Completed

Will output:, (*7)

  • app/Repositories/Eloquent/Criteria/Completed.php

Configurations

If somehow you cannot publish the config/repoist.php from artisan here you can copy and use it., (*8)

<?php

return [

    /**
     * Namespaces are being prefixed with the applications base namespace.
     */
    'namespaces' => [
        'contracts' => 'Repositories\Contracts',
        'repositories' => 'Repositories\Eloquent',
    ],

    /**
     * Paths will be used with the `app()->basePath().'/app/'` function to reach app directory.
     */
    'paths' => [
        'contracts' => 'Repositories/Contracts/',
        'repositories' => 'Repositories/Eloquent/',
    ],

];

Configurations

Default methods of the Kurt\Repoist\Repositories\Eloquent\AbstractRepository., (*9)

Method Usage
all $repo->all()
find $repo->find($id);
findWhere $repo->findWhere($column, $value);
findWhereFirst $repo->findWhereFirst($column, $value);
findWhereLike $repo->findWhereLike($column, $value, $paginate = 0);
paginate $repo->paginate($perPage = 10);
create $repo->create(array $properties);
update $repo->update($id, array $properties);
delete $repo->delete($id);

Example Usage

Customer.php, (*10)

<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Customer extends Model
{
    /**
     * Customer has many Tickets.
     *
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     */
    public function tickets()
    {
        return $this->hasMany(Ticket::class, 'customer_id', 'id');
    }
}

EloquentCustomerRepository.php, (*11)

<?php
namespace App\Repositories\Eloquent;

use App\Models\Customer;
use App\Repositories\Contracts\CustomerRepository;
use Kurt\Repoist\Repositories\Eloquent\AbstractRepository;

class EloquentCustomerRepository extends AbstractRepository implements CustomerRepository
{
    public function entity()
    {
        return Customer::class;
    }
}

PagesController.php, (*12)

<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Repositories\Contracts\CustomerRepository;
use Kurt\Repoist\Repositories\Eloquent\Criteria\EagerLoad;

class PagesController extends Controller
{
    private $customerRepository;

    function __construct(CustomerRepository $customerRepository)
    {
        $this->customerRepository = $customerRepository;
    }

    public function getHome()
    {
        $customersWithTickets = $this->customerRepository->withCriteria([
            new EagerLoad(['tickets']),
        ])->all();

        return $customersWithTickets;
    }
}

The Versions

10/03 2018

dev-master

9999999-dev

Laravel 5.6 repository generator.

  Sources   Download

MIT

The Requires

 

The Development Requires

database laravel repository repoist

10/03 2018

3.0.0

3.0.0.0

Laravel 5.6 repository generator.

  Sources   Download

MIT

The Requires

 

database laravel repository repoist

25/11 2017

2.0.4

2.0.4.0

Laravel 5.5 repository generator.

  Sources   Download

MIT

The Requires

 

database laravel repository repoist

20/11 2017

2.0.3

2.0.3.0

Laravel 5.5 repository generator.

  Sources   Download

MIT

The Requires

 

database laravel repository repoist

04/11 2017

5.5.x-dev

5.5.9999999.9999999-dev

Laravel 5.5 repository generator.

  Sources   Download

MIT

The Requires

 

database laravel repository repoist

04/11 2017

2.0.2

2.0.2.0

Laravel 5.5 repository generator.

  Sources   Download

MIT

The Requires

 

database laravel repository repoist

18/01 2017

5.4.x-dev

5.4.9999999.9999999-dev

Laravel 5 repository generator.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repoist

13/01 2016

1.1.x-dev

1.1.9999999.9999999-dev

Laravel 5 repository generator.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repoist

15/05 2015

1.0.1.x-dev

1.0.1.9999999-dev

Laravel 5 repository generator.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repoist

15/05 2015

1.0.1

1.0.1.0

Laravel 5 repository generator.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel repoist