Answer the question
In order to leave comments, you need to log in
How can I correctly build the architecture of an application piece?
The data contains cabinets and a corresponding hourly record.
cabinets:
|id|
|1|
|2|
Records:
| cabinet_id | date | time | value |
I want to try to create an architecture based on storing data in repositories.
There is a controller action that renders a record for the day.
In my understanding, there is an interface of the cabinet repository, inside the implemented repository (interface implementations, quarrel for French), there is a factory that creates this cabinet, there is a cabinet class where I get cabinet records from the database in the constructor.
I don’t understand how I can connect the factory and the repository at what stage. Or do I need to sculpt two repositories inside the action, one SQL, the second memory, and do this SQLRepo-> Factory -> MemoryRepo so that everything meets the standards.
And to catch up, am I doing the right thing by getting an entry in the cabinet constructor?
Answer the question
In order to leave comments, you need to log in
in simple terms:
Controller{
protected $cabinetRepo;
protected $zapisRepo;
function __constructor(CabinetRepository $cabinetRepo, ZapisRepository $zapisRepo ){
$this->zapisRepo = $zapisRepo;
$this->cabinetRepo = $cabinetRepo;
}
public function action(){
$zapisCollection = $this->zapisRepo->findOnCurrentDay();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question