In controller
class acontroller extends Controller
{
private $variable;
public function __construct(){
$this->variable;
}
public function first(){
$calculation = 1 + 1;
$this->variable = $calculation;
return view('something.view');
}
public function second(){
dd($this->variable);
return view('something.view2');
}
}
This is an example. What I'm trying to do is to pass the calculation result in first method to the second. I am expecting in second method inside dd() to show the result 2 but instead of this I am getting null.
What is going wrong and how to fix this?