Laravel-Challenge-Route-Model-Binding icon indicating copy to clipboard operation
Laravel-Challenge-Route-Model-Binding copied to clipboard

Fixes bugs and implements tests (with explanation on why problem 3 can throw 2 errors)

Open archilex opened this issue 3 years ago • 2 comments

archilex avatar Jul 25 '21 06:07 archilex

For those wondering why problem 3 sometimes throws an error and other times shows incorrect information, route model binding will attempt to match the first numerical part of the string to a model. As long as the string (UUID in this case) starts with a number and that number is a valid ID, it will show that ID.

transactions/4asfasdf/duplicate will find Transaction::findOrFail(4) transactions/12zxcvxcv/duplicate will find Transaction::findOrFail(12)

However if the UUID starts with a letter or the number is not a valid transaction ID then it will throw a 404 transactions/asdfasdfasd/duplicate will throw a 404 transactions/12345zxvzczcv/duplicate will throw a 404 because 12345 is not a valid transaction id since there are only 100 seeded transactions.

archilex avatar Jul 25 '21 07:07 archilex

@archilex with the test and uuid explanation? AWESOME job!

PovilasKorop avatar Jul 25 '21 09:07 PovilasKorop