Вот примитивный пример моего приложения:
namespace App\Repositories;
use App\Interfaces\InterfaceRepository;
class RepositoryDictionary implements InterfaceRepository
{
public $model;
public function __construct(\Dictionary $model);
public function find($id);
public function all();
public function byRaw($column, $st, $raw);
public function update($id, array $sets);
}
Следовательно все это дело потом в контроллер:
class DictionaryController extends BaseController
{
public $dictionary;
public function __construct(RepositoryDictionary $repositoryDictionary)
{
$this->repositoryDictionary = $repositoryDictionary;
}
}
А теперь вопрос: почему нельзя сделать вот так:
class DictionaryController extends BaseController
{
public $dictionary;
public function __construct(Dictionary $model)
{
$this->repositoryDictionary = $model;
}
}
Репозиторий-класс же в себе ничего не хранит? Какой в нем толк?