PHP code example of vivek-mistry / repository-interface

1. Go to this page and download the library: Download vivek-mistry/repository-interface 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/ */

    

vivek-mistry / repository-interface example snippets


    public function boot(): void
    {
        $this->app->bind(
            INTERFACE_NAME::class,
            REPOSITORY_NAME::class
        );
    }

class UserController extends Controller
{
    protected $userRepository;

    /**
     * Load Repository
     */
    public function __construct(
        UserRepositoryInterface $userRepository
    ) {
        $this->userRepository = $userRepository;
    }

    public function index($request)
    {
        $data = [
            'name' => $request->name,
            'email' => $request->email
        ];
        $this->userRepository->createOrUpdate($data);
    }
}

composer test
bash
php artisan app:make-repo {ModelName}
bash
php artisan make:provider RepositoryServiceProvider