F
F
fapchat2022-03-04 03:46:19
PHP
fapchat, 2022-03-04 03:46:19

How to permanently forward a variable from the controller to the view?

See, I need that when passing a variable to the view from the controller

spoiler
//тут - переменной email
   return view('personalOffice')->with('email', $_POST['email']);

I could get the value of the variable in it even when I return the view from somewhere else.
Those. in web.php file i want code like this
spoiler
Route::get('/', function () {
    if (Auth::check()) {
        return redirect(route('personalOffice'));
    }
    return view('welcome');
})->name('welcome');

Route::view('/personalOffice', 'personalOffice')->middleware('auth')->name('personalOffice');

didn't stop me from getting the variable in the personalOffice view. That is, even if the user is redirected not because of a method in the controller, but because of the code in the web.php file, I need to be able to get the email variable in the personalOffice view.
How to implement all this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vism, 2022-03-04
@vism

given the code, just put $_POST['email'] right in the view :) It won't get any worse

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question