PHP code example of mohammadmehrabani / repository-generator

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

    

mohammadmehrabani / repository-generator example snippets


'providers' => [
    // for laravel 5.4 and below
    MohammadMehrabani\RepositoryGenerator\RepositoryGeneratorServiceProvider::class,
];

'providers' => [
    // You can change service_provider_class from config/repository-generator.php
    App\Providers\RepositoryServiceProvider::class,

],
 bash
php artisan vendor:publish --provider="MohammadMehrabani\RepositoryGenerator\RepositoryGeneratorServiceProvider" --tag="config"
 bash
php artisan repository:generate
 php


// You can change Directories and Namespaces from config/repository-generator.php
use App\Repositories\Interfaces\UserRepositoryInterface;

$repository = resolve(UserRepositoryInterface::class);
$user      = $repository->select('id', 'name')
                         ->where('name', 'LIKE', '%Mohammad%')
                         ->first(); // or ->get();
 php


use App\Repositories\Interfaces\UserRepositoryInterface;

$repository = resolve(UserRepositoryInterface::class);
$users      = $repository->active()
                         ->get();
            
// You can change active column name from config/repository-generator.php