私はLaravelのコース登録に関するレポートを作成するクラスを持っています。以下は私のクラスです:Laravelの集計注射
Laravelは、ユーザー、コース、および登録モデルのインスタンスをレポートに自動的に挿入します。 レポートを作成するために使用する必要がある他のModelクラスがもっと必要な場合は、Reportのコンストラクタにさらに引数を追加する必要があります。
class Report {
protected $user;
protected $course;
protected $registration;
public function __construct(User $user, Course $course, Registration $registration, Another1 $another1, Another2 $another2, ...) {
$this->user = $user;
$this->course = $course;
$this->registration = $registration;
}
public function build() {
// build report
}
}
これは正しい方法ですか? Reportクラスで使用されるクラスを集約する他の方法はありますか? Facade Patternを使用してリファクタリングする必要がありますか?
何か助けていただければ幸いです。