I am passing 2 random numbers from controller to view with form:
public function request()
{
$number1 = rand(10,20);
$number2 = rand(0,10);
return View::make('request', ['num1' => $number1, 'num2' => $number2]);
}
These 2 numbers are displayed in form:
{{ Form::open(array('action' => 'MyController@verifyRequest', 'class'=>'bg-grey width')) }}
{{ Form::label('Check sum: ') }}
{{ Form::label($num1. ' + '. $num2. ' = ') }}
{{ Form::text('checksum') }}
{{ Form::close() }}
Now how can I pass those two variables into controller method 'verifyRequest' to check sum of the numbers?
public function verifyRequest()
{
$sum = ???
You can either put those data into session (what might be better solution) or add hidden fields into form:
and now in your controller you can use: