PHP code example of adamkhoa03 / eloquent-repository
1. Go to this page and download the library: Download adamkhoa03/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/ */
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 Adamkhoa03\EloquentRepository\EloquentRepository;
class HomeController extends Controller
{
public function index(EloquentRepository $repository)
{
return $repository->setEntity(User::class)->get();
}
}