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

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -