Answer the question
In order to leave comments, you need to log in
Do I need to create a Repository Class for every table in the database?
I have a database with data, I want to write a Laravel application for it. In the table itself, much of the data is broken into tables with one-to-one relationships.
I can’t understand - do I need to write a repository for each table, or just specify one repository and the rest of the tables as dependencies?
Answer the question
In order to leave comments, you need to log in
https://learnxinyminutes.com/docs/python3/
learn python the hard way
I think that after the first book you need to start doing something. The fact is that book knowledge, divorced from reality, is worth nothing (and will be instantly forgotten). Only real development experience will show in which direction to move, and what knowledge is missing.
If we are talking about something like this
bosnadev.com/2015/03/07/using-repository-pattern-i...
then the requests (and in fact the functions in the repository are questions) are
added to the repository whose lines you are pulling out
and whose lines are more important
Example
ItemRepository
{
public function getItems($criteria)
{
$this->applyCriteria($criteria);
$this->join(
'addresses',
'LEFT JOIN addresses ON addresses.item_id = items.id'
);
$this->addSelect('*');
return $this->findAll();
}
public function getSumSize($criteria)
{
$this->applyCriteria($criteria);
$this->join(
'legs',
'LEFT JOIN legs ON legs.item_id = items.id'
);
$this->addSelect('items.id');
$this->addSelect('sum(legs.size)');
return $this->getCell();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question