Laravel cast route parameter to Integer
问题 I really like the idea of Route Model Binding . Is there a similar way to cast parameters (which are Strings) to Intergers? The reason is that I often have the parameters year and month , but I would like to have it as an Integer, because the database seems to handle String and Integers in different ways. 回答1: Yes there is. You can use Route Binding similar to what I answered here. It's unfortunate that it exists but is not documented in the Laravel docs. 回答2: Update using PHP7, if anyone