php - How to put a parameter in a Laravel controller method not obligatory? -
I do not know how to make the parameters mandatory in the Laravel controller method, because I found a route (I I am saying that it is not mandatory):
Route: Received ('/ account / student / create / {student_id?}', Array ('as' = & Gt; 'Account-Student-Building', 'Usage' = & gt; Student-Controller @ Get Crelet));
I got it in my controller:
getCreate ($ student_id) {...}
if If no parameter fills in the path then I have received the warning message:
Logic 1 for StudentController 1: getCreate ()
Thanks for helping !
Gene
Add a default value to declare your controller method: < / P>
getCreate {$ student_id = null} {...}
Such a method when the method is called without a value, $ student_id
will be set to clear.
Comments
Post a Comment