Laravel 5 : [Call to a member function getAction() on a non-object

前端 未结 2 1173
自闭症患者
自闭症患者 2021-01-22 20:14

In my Controller, I have

Route::getCurrentRoute()->getAction()[\'as\']

Everything works well in the browser but as soon as I type



        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-22 20:25

    Seems obvious doesn't it?

    Get current route in a browser will return the currently visited route. In the terminal you do not have such a request. Laravel will return null when asking what route is visited. You would have to check for the return value before calling getAction.

提交回复
热议问题