Run function from Button or URL in Laravel

夙愿已清 提交于 2019-11-29 05:17:51

Here is the solution:

We assume you have a function callMeDirectlyFromUrl in YourController, here how you can call the function directly from URL, Hyperlink or Button.

Create Route

Route::get('/pagelink', 'YourController@callMeDirectlyFromUrl');

Add link in the view blade php file

<a href="{{action('YourController@callMeDirectlyFromUrl')}}">Link name/Embedded Button</a>

This has been tested on Laravel 4.2 -> 5.2 so far.

By clicking on this link or call the URL www.somedomain.com/pagelink the function will executed directly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!