Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Dependency Injection to retreive model instance on the controller handler #42

Open
Brivan-26 opened this issue Sep 27, 2023 · 0 comments
Labels
good first issue Good for newcomers Refactor refactor

Comments

@Brivan-26
Copy link
Member

Currently, for all controller handlers that require dealing with a record on a database, we're passing the id of the instance and fetching the corresponding instance on the controller and doing the stuff required. It's more clean to make a DI on the controller to retrieve the model instance directly.
Changing from this for example:

public function unlockById($id) {
        $track = Track::find($id);
        // other stuff
}

To this:

public function unlockById(Track $track) {
        // other stuff
}
@Brivan-26 Brivan-26 added good first issue Good for newcomers Refactor refactor labels Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Refactor refactor
Projects
None yet
Development

No branches or pull requests

1 participant