I have multiple DAO classes (or Repository classes in Laravel jargon).
<?php
namespace App\Repository;
class CompanyRepository extends RepositoryFactory
{
public function getCompany($id)
{
$q = "SELECT COMPANY FROM `COMPANIES` WHERE ID > :id1";
$result = DB::select($q, ["id1" => $id]);
return $result;
}
}
?>
<?php
namespace App\Repository;
class ArticleRepository extends RepositoryFactory
{
public function createArticle($title, $summary)
{
….
}
}
?>
Now I would like for one class to include once all my Repositories (30-40 Repositories) with a class such as RepositoryInclude
<?php
namespace App\Repository;
use App\Repository\ArticleRepository;
use App\Repository\CompanyRepository;
use ….
class RepositoryInclude
{
}
?>
so that from my Controller I could simply:
use App\Repository\RepositoryInclude;
class MYController extends Controller
{
public function __construct(CompanyRepository $companyRepository)
{
$this->companyRepository = $companyRepository;
}
public function index()
{
$companyNameList = $this->companyRepository->getCompany();
}
}
How can I do that? apparently nesting classes with a hierarchy of "use" doesn't work as if I nest a series of "include_once".
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l4E7xT
via IFTTT
Aucun commentaire:
Enregistrer un commentaire