Factors to Consider When Choosing Accounts Payable Services Providers.pptx
How to send hidden value from blade to laravel controller?
1. How to send hidden value
from blade to laravel
controller?
You need to use a form to do it. In your blade create a form like
below
<div>
<form method="post" action="/learn-laravel">
{{csrf_field()}}
<button class="btn-class" type="submit">View
laravel tutorials</button>
<input type="hidden" value="7" name="any-
name">
</form>
</div>
In your form, you need to mention the hidden field type, name
and value with a input tag. Since this is a post request, the
data value would be sent to the controller in your "any-name"
variable.
Decleare a route like this below
Route::post('your-url', 'NameController@yourFunction');
In the route the first parameter is the same the name of your
2. action method in the form. Second parameter the first is the
controller name and last section is the function name.
Within form the method must be post method. In your
controller do like this
public function yourFunction(Request $request){
$id=$request->any-name;
}
Now the variable $id would contain the value passed from
laravel blade.