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

Controllers methods should return 404 for invalid ids #46

Open
adwiv opened this issue Dec 17, 2024 · 2 comments · May be fixed by #48
Open

Controllers methods should return 404 for invalid ids #46

adwiv opened this issue Dec 17, 2024 · 2 comments · May be fixed by #48

Comments

@adwiv
Copy link
Contributor

adwiv commented Dec 17, 2024

The show and edit routes may result in errors since we use find($id) which returns null if id is not found.

This results in a null model being passed to the view.

We should instead use findOrFail which results in 404 if id does not exist.

@awais-vteams
Copy link
Owner

I would be happy if you pushed the PR. I'll be checking in the next release.

@adwiv
Copy link
Contributor Author

adwiv commented Dec 17, 2024

Sure. Should I fix it as suggested in #24 (Controller signatures should use Models instead of IDs)

This would shorten the code and the controller signatures will match the api controller signatues with already uses Models.

adwiv added a commit to adwiv/laravel-crud-generator that referenced this issue Dec 17, 2024
@adwiv adwiv linked a pull request Dec 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants