Laravel passing data from view to controller.
Hi guys, Today i just make tutorial on simple task to pass data from laravel blade view to the controller. Its really simple to do. I setup just new laravel application. In ‘web.php’ file add two routes as —
In test method in controller ‘Controller’, i just passed array of words to the view called ‘test’. Showed in image —
Now by doing this we can asses array in blade view. I think everybody already know that. Now, here need to pass these data to the controller. For that i just created a form and set the hidden input for these array in foreach loop.
Form submit a post request to the route named ‘test.store’. (Already created .) Into the ‘testData’ method i just return all.
Output in browser is —
Now we can use this array as we want in controller.
We can also do like -
and we get —
Leave like if you found this helpful.