PHP code example of nda666 / laravel-repository-pattern
1. Go to this page and download the library: Download nda666/laravel-repository-pattern 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/ */
nda666 / laravel-repository-pattern example snippets
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
class HomeController extends Controller
{
protected UserRepository $user;
public function __construct(UserRepository $user)
{
$this->user = $user;
}
public function index()
{
return $this->user->getAll();
}
}
shell
php artisan vendor:publish --provider="LaravelRepositoryPattern\Providers\RepositoryPatternProvider"
shell
php artisan make:repository User