PHP code example of orkhanahmadov / eloquent-repository
1. Go to this page and download the library: Download orkhanahmadov/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/ */
orkhanahmadov / eloquent-repository example snippets
php
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
class HomeController extends Controller
{
public function index(UserRepository $userRepository)
{
return $userRepository->get();
}
}
php
namespace App\Http\Controllers;
use App\User;
use Orkhanahmadov\EloquentRepository\EloquentRepository;
class HomeController extends Controller
{
public function index(EloquentRepository $repository)
{
return $repository->setEntity(User::class)->get();
}
}