PHP code example of jason-guru / laravel-make-repository

1. Go to this page and download the library: Download jason-guru/laravel-make-repository library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jason-guru / laravel-make-repository example snippets


public function __construct(private UserRepositoryInterface $users) {}

return [
    'path'           => 'app/Repositories',
    'namespace'      => 'App\\Repositories',
    'with_interface' => true,  // generate a paired interface
    'bind'           => true,  // auto-bind interface => concrete
];



namespace App\Repositories;

use App\Models\User;
use App\Repositories\Contracts\UserRepositoryInterface;
use JasonGuru\LaravelMakeRepository\Repository\BaseRepository;

class UserRepository extends BaseRepository implements UserRepositoryInterface
{
    public function model(): string
    {
        return User::class;
    }
}
bash
php artisan make:repository UserRepository
bash
php artisan make:repository Backend\\UserRepository
bash
php artisan make:repository UserRepository --model=User
bash
php artisan vendor:publish --tag=repository-config