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()
{
return "I have been called from URL :)";
}
My Question: Is it possible to call a function directly from button-click or URL link from the blade view in Laravel?
Here is the solution:
We assume you have a function
callMeDirectlyFromUrl
inYourController
, here is how you can call the function directly from a URL, Hyperlink, or Button.Create Route
Add link in the view blade php file
This has been tested on Laravel 4.2 -> 5.2 so far.
By clicking on this link or calling the URL
www.somedomain.com/pagelink
the function will be executed directly.