I'm trying to create a variable accessible by two different controller functins in laravel. How can I do that. The first function gets a value from a blade, it stores it in a variable and then I want to pass that variable with value to another controller function. For example, the following blade passes obj_id to controller:
1) My blade:
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head>
<title>test</title>
</head>
<body>
<form method='post' action="/hard">
{{csrf_field()}}
<br>
<legend><i> Fill Data </i></legend>
<br>
<label>
OBJECT ID:
<input name='obj_id' type='text' minlength="8" required="" oninvalid="this.setCustomValidity('8 char at least')">
</label>
<br>
<input type='submit' value="Submit!">
</form>
<br>
<br>
</body>
</html>
2) My controller function Roger correctly gets obj_id (I have tested ot with dd)
public function Roger(Request $p)
{
$t = $p-> get('obj_id'); //I want $t to be global variable
//dd($t);
}
3) and then I want to pass $t to function Roger1 in the same controller
public function Roger1()
{
dd($t);
}
I have tried to declare $t as global with no success. I'm a little bit confused with $this and tried several combinations with no success.
Could you assist please?