1. Go to this page and download the library: Download jetcod/eloquent-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/ */
jetcod / eloquent-repository example snippets
namespace App\Repositories;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Jetcod\LaravelRepository\Eloquent\BaseRepository
class UserRepository extends BaseRepository
{
protected function getModelName()
{
return User::class;
}
}
namespace App\Services;
use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Jetcod\LaravelRepository\Eloquent\BaseRepository
class UserService
{
protected $repository;
protected function __construct(UserRepository $repository)
{
$this->repository = $repository;
}
public function getAdmins()
{
return $this->repository->findBy([
['role', '=', 'ADMIN']
]);
}
}
sh
php artisan make:repository UserRepository
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.