CRUD
CRUD copied to clipboard
remove anonymous function
WHY
BEFORE - What was wrong? What was happening before this PR?
Using the anonymous class to extend the request class was leading to problems when parallel testing. https://github.com/Laravel-Backpack/CRUD/issues/4389 I always thought that this anonymous class solution was either genious or stupid, guess what I found out ? 🤡
AFTER - What is happening after this PR?
I found out a better solution to merge the rules/messages in the request and validate it.
HOW
How did you achieve that, in technical terms?
Looked at it with a fresh perspective! 🙄
Is it a breaking change?
no
How can we test the before & after?
everything should keep working/validating when using this 👍
Haha that's some great copy there @pxpm 😅 I'll let @promatik review and test this first, since it needs extensive testing. We gotta be sure nothing breaks.
@promatik I refactored as per our comments.
I think this cover all the cases, can you give this a new go and let me know if you found any inconsistency ?
Cheers
@pxpm let's please add unit tests for this. A bunch of them - covering all combinations of the types of validations we have... in all possible orders:
- FormRequest
- Array
- Field
Hello @tabacitu I've just finished writing the tests for the validation class and I merged them here.

I assigned @jorgetwgroup to review the PR, but I think we are done here and can merge this as it is.
Cheers
OMG SO MUCH GREEN! I LOVE IT!

This being an important part of the form... let's let @jorgetwgroup give this a quick manual test anyway, to make sure nothing's breaking. If we have GREEN LIGHT from him too (🤭), free to merge @pxpm
hi @pxpm
First you know im not expert on test files, but always when i run this test i get this error.
I have this branches: CRUD: refactor-request-anonymous-function (this) PRO: main Demo: main
Let me know if i miss something.
Cheers.
Hey @jorgetwgroup so sorry, my bad! 😞
addFields() should be an array of arrays, not an array of fields. Dumb mistake!
I fixed it, and took the opportunity to better write a test that I was not 100% confortable with. Now I am 👍
If you think this is ready after my last commit, let's do this 💪
Hello @pxpm as we check everything is working now.
Look ready to merge.
Thanks.
The inspection completed: 12 new issues, 15 updated code elements