-1

そのため、Laravel フレームワークを使用して PHP で Web アプリを開発しています。12 個のモデルと 1 個のコントローラー、およびモデルにリンクする 12 個のリポジトリーがあります。各リポジトリで、クエリを使用していくつかの関数を作成しているため、コントローラーで繰り返されません。コントローラー コンストラクターにリポジトリを挿入しようとしていますが、リポジトリの数が多すぎます。

いつもは1~2本と聞いていたのですが、今のところ12本持っています。

コントローラ:

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;
}
}
4

1 に答える 1