Skip to content

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

@Brivan-26

Description

@Brivan-26

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
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions