Run function from Button or URL in Laravel

前端 未结 1 1908
感情败类
感情败类 2020-12-18 11:14

I have the following test function, that I want to call directly from my URL or by clicking a link from my blade view.

public function callMeDirectlyFromUrl(         


        
相关标签:
1条回答
  • 2020-12-18 11:22

    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.

    0 讨论(0)
提交回复
热议问题