Might be a silly question to ask, but it's best to ask it anyway. When a user logs in, they should be redirected to the store page, and not be able to see the login page again. However, when a user logs in the return to the login page, as if they never got in, but they can see they're in with the navbar by seeing their user name.
The redirect works fine when the logout however.
This is the login page:

```
@extends('template')

@section('content')
<h1> Welcome, please log in </h1>
<div class="row">
    <div class="col-md-8">
        <form class="clearfix" method="post" action="{{url('login')}}">
            @csrf
            <div class="form-group">
                <label for="email1">Email address</label>
                <input type="email" class="form-control" id="email" name="email"">
            </div>
            <div class="form-group">
                <label for="password"> Password </label>
                <input type="password" class="form-control" id="password" name="password">
            </div>
            <button type="submit" class="btn btn-primary float-right"> Login </button>
        </form>
    </div>
</div>
@endsection

```

This is the controller the function is at:

```
<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Http\Requests\UserSignup;
use Illuminate\Http\Request;
use App\Models\User;
use App\Http\Requests\UserLogin;

class UserController extends Controller{

    public function logout(Request $request) {
        $name = session('name');
        $request->session()->flush();
        return redirect('shop')->with('status', 'Bye bye ' . $name);
    }

    public function processLogin(UserLogin $request) {
        if(User::loginUser($request)){
            if(session('place-order-process')){
                $request->session()->forget('place-order-process');
                return redirect('shop');
            }
        return redirect('shop')->with('status', 'Welcome, ' . ucfirst(session('name')) . 'enjoy your time here at the club!');
        }
        return redirect('login')->with('status-fail', 'Wrong email or password');
    }

    public function displayLogin(){
    return view ('user.login');
    }       

    public function processSignup(UserSignup $request) {
        \App\Models\User::store($request);
        return redirect('login');
    }

    public function displaySignup(){
        return view ('user.signup');
    }
}

```

and the model, in case needed:

```
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Hash;

class User extends Model {

    public function role() {
        return $this->belongsTo('App\Models\Role');
    }

    public static function deleteUser($id) {
        elf::destroy($id);
    }

    public static function getUser($id) {
        return self::findOrFail($id);
    }

    public static function getUsers() {
        return self::orderBy('name')->get();
    }

    public static function loginUser($request) {
        $user = self::where('email', $request->email)->first();
        if (!$user || !Hash::check($request->password, $user->password)) {
            return false;
        }
        session([
            'name' => $user->name,
            'role' => $user->role_id,
            'id' => $user->id,
        ]);
    }

    public static function editUser($request, $id) {
        $user = self::findOrFail($id);
        $user->name = $request->name;
        $user->email = $request->email;
        if ($user->id != session('id)')) {
            $user->role_id = $request->role ?? 69;
        } else {
            session(['name => $request -> name']);
        }
        if ($request->password) {
            $user->password = bcrypt($request->password);
        }
        $user->save();
    }

    public static function store($request) {
        $user = new self();
        $user->name = $request->name;
        $user->email = $request->email;
        $user->password = bcrypt($request->password);
        $user->role_id = $request->role ?? 69;
        $user->save();
    }

    //use HasFactory;
}

```