1. Go to this page and download the library: Download morilog/flexible-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/ */
morilog / flexible-repository example snippets
namesapce App\Reposiotries;
use Morilog\FlexibleRepository\Contracts\RepositoryInterface;
interface UserRepository extends RepositoryInterface
{
}
namespace App\Repositories;
use Morilog\FlexibleRepository\BaseEloquentRepository;
use App\Models\User;
class EloquentUserRepository extends BaseEloquentRepository implements UserRepository
{
protected function model()
{
return User::class;
}
}
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Repositories\UserRepository;
use App\Repositories\EloqeuntUserRepository;
class RepositoryServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(UserRepository::class, function ($app) {
return new EloquentUserRepository($app);
});
// or
// $this->app->bind(UserRepository::class, EloquentUserRepository::class);
}
}
namespace App\Http\Controllers;
use App\Repositories\UserReposiotry;
class UsersController extends Controller
{
public function index(UserRepository $repository)
{
return $repository->all();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.