PHP code example of wimski / laravel-model-repositories
1. Go to this page and download the library: Download wimski/laravel-model-repositories 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/ */
wimski / laravel-model-repositories example snippets
namespace App\Providers;
use Wimski\ModelRepositories\Providers\ModelRepositoryServiceProvider;
class RepositoryServiceProvider extends ModelRepositoryServiceProvider
{
protected array $repositories = [
// add your repository bindings here
];
}
class SomeService
{
protected MyModelRespositoryInterface $repository;
public function __construct(MyModelRespositoryInterface $repository)
{
$this->repository = $repository;
}
public function doSomething($id): void
{
$myModel = $this->repository->findOrFail($id);
}
}