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

Move ResourceController model actions to separate methods. #11

Closed
thomasowow opened this issue Oct 24, 2019 · 0 comments · Fixed by #12
Closed

Move ResourceController model actions to separate methods. #11

thomasowow opened this issue Oct 24, 2019 · 0 comments · Fixed by #12
Labels
enhancement New feature or request

Comments

@thomasowow
Copy link
Member

As mentioned in #7 we constantly have to copy the whole method when only changing the model "action" part. The model action could be retrieving, storing, updating...

A new proposal is to separate these action calls in new methods so the overwriting is minimal. The following example would make this clearer.

// ResourceController
public function index()
{
    ... default stuff

    $models = $this->indexModel();

    ... default stuff
}

public function indexModel()
{
    return $this->resourceModelClass::paginate();
}

// My custom controller
public function indexModel()
{
    return $this->resourceModelClass::with('relation')->paginate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant