php - How to check if this is a visitors first visit Laravel Updated

I am making a test crypto wallet and I would like my index to redirect to the key setup if this is their first visit currently I have sessions database set up with a boolean for the first visit with a default value of true that is changed to false when the page loads I have tried using middleware one that runs before loading as below:
public function handle(Request $request, Closure $next){
(session('first_visit') ? session(['first_visit => 'false']) : session(['first_visit' =>
'true']));
return $next($request);
and one that loads after the page does that's set up like this:
public function handle(Request $request, Closure $next){
$responce = $next($request);
session(['first_visit' => 'false']);
return $responce;
in my controller, I've done this:
public function first_visit(Request $request){
return view('welcome', ['first_visit' => session('first_visit')]);
}
I installed debugbar and I see this array under requests:
array:5 [▼
"first_visit" => "false"
"_token" => "9rKGFbTm5WeSYJFBw25L8DQZ6ofb8I9grdWg48BZ"
"_previous" => array:1 [▶]
"_flash" => array:2 [▶]
"PHPDEBUGBAR_STACK_DATA" => []
]
inside my welcome.blade.php file I have @if($first_visit) then the code for the first visit page with @else for the usual homepage code I am always shown what's inside the if statement unless I put @if(!$first_visit) there's no requests listed to set first_visit from the page what am I doing wrong?
EDIT: I have changed the code as the comment still having an issue after setup and displaying the homepage code within the else statement it defaults back to true and I see the first visit page again question now would be is my statement at fault or is it because the default value is true?
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: too few arguments to function laravel
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.