laravel-repository maintained by 0x17
Description
This is a package that help to implement repository pattern in laravel
Author
Last update
2023/08/13 14:46
(dev-master)
License
Downloads
35
Laravel Repository
This is a package that help to implement repository pattern in laravel
Installation
The first step is using composer to install the package and automatically update your composer.json file, you can do this by running:
composer require 0x17/laravel-repository
Usage/Examples
create dto
php artisan make:dto User
create service class
php artisan make:service User
create repository class
php artisan make:repository User
Register UserRepository:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Repositories\Interfaces\IUserRepository;
use App\Repositories\UserRepository;
use App\Models\User;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
$this->app->bind(IUserRepository::class, function () {
return new UserRepository(new User());
});
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}