所以我正在使用Laravel框架在PHP中开发一个Web应用程序。我有12个模型和1个控制器,以及12个连接到模型的存储库。在每个存储库中,我正在用查询编写一些函数,因此它们不会在控制器中重复使用。我试图在控制器构造函数中注入存储库,并且不知道它们中有多少是太多?我听说,它的1或2平常,但我有12个到目前为止。PHP最大数量的存储库
控制器:
class PagesController extends Controller {
protected $review;
protected $organization;
protected $user;
protected $city;
protected $buyer;
protected $employee;
public function __construct(ReviewRepository $review, OrganizationRepository $organization, UserRepository $user, CityRepository $city, BuyerRepository $buyer, EmployeeRepository $employee) { //here are just 6 repositories, I have much more
$this->employee = $employee;
$this->city = $city;
$this->buyer = $buyer;
$this->user = $user;
$this->organization = $organization;
$this->review = $review;
}
库:
class ReviewRepository {
protected $review;
function __construct(Review $review)
{
$this->review = $review;
}
}