Laravel-Challenge-Route-Model-Binding
Laravel-Challenge-Route-Model-Binding copied to clipboard
Fixes bugs and implements tests (with explanation on why problem 3 can throw 2 errors)
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 with the test and uuid explanation? AWESOME job!