php - How can I use variables from a form globally in Laravel 8?

I want to use a variables from a form globally but I don't know how do it with Laravel 8
<div class="form-group" style="margin-top: 2%;">
<label for="alfabetoAutomata">Alfabeto</label>
<input type="text" class="form-control" name="alfabetoAutomata" id="alfabetoAutomata" title="Debe ingresar el alfabeto como el siguiente ejemplo: a,b,c" pattern="^[a-zA-Z0-9]+(,[a-zA-Z0-9]+)*$" placeholder="Ingrese el alfabeto para los autГіmatas separados por comas. (Ej: a,b,c)" autocomplete="off" value="<?php echo htmlspecialchars($_GET['alfabetoAutomata'] ?? '', ENT_QUOTES); ?>" required>
</div>
I want to use the var$_GET['alfabetoAutomata']
globally, how I can do it?
I hope I have made myself understood, thank you very much!
Answer
Solution:
Check out the View::share documentation. https://laravel.com/docs/8.x/views#sharing-data-with-all-views If that is not what you are looking for, then I would suggest, inside your controller, set a session variable like this.
Session::put('foo', 'bar')
Above foo is the name of the variable and bar is the value. Now, when I need to change the value of foo, for example in a blade file, I can do so like this.
{{Session::put('foo','Another Bar')}}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: foreach() argument must be of type array|object, null given
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.