所以我正在使用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;
}
}