You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's imagine application, with master-slave replication.
We have master and slave databases and thus `MasterFilesRepository` works with master and `SlaveFilesRepository` works with slave one.
In our controller methods depend on `FilesRepository` interface, which is implemented by classes described above.
final class FilesController extends Controller
{
public function index(FilesRepository $filesRepository) // works with slave database
{
return view('pages.client.dashboard.files.index', [
'files' => $filesRepository->all()
]);
}
public function edit(int $id, FilesRepository $filesRepository) // works with master database
{
return view('pages.client.dashboard.files.edit', [
'file' => $filesRepository->find($id)
]);
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Let's imagine application, with master-slave replication.
We have master and slave databases and thus `MasterFilesRepository` works with master and `SlaveFilesRepository` works with slave one.
In our controller methods depend on `FilesRepository` interface, which is implemented by classes described above.
It would be wonderful to write like so:
Beta Was this translation helpful? Give feedback.
All reactions