Laravel 5.4: Authentication System I have recently coded my own authentication system and wondered if there was any way I could make it better? I coded it with Laravel 5.4. getView is called on Route::get and onPost is called on Route::post
    

use Auth;
use App\User;
use App\Http\Controllers\Controller;
use Validator;
use Redirect;
use Illuminate\Http\Request;
use App\Database\Frontend\User\Player;
use App\Database\Frontend\WebsiteLogin;

class LoginController extends Controller
{
    public function getView()
    {
        return view('frontend.login');
    }

    public function onPost(Request $request) 
    {
        $validator = Validator::make($request-&gt;all(), [
            'mail'     =&gt; 'required|email|exists:users',
            'password'  =&gt; 'required'
        ]);

        if ( $validator-&gt;fails()) {
            return Redirect::to('/login')-&gt;withErrors($validator-&gt;messages());
        }
        else {
            if (!Auth::attempt(['mail' =&gt; $request-&gt;input('mail'), 'password' =&gt; $request-&gt;input('password')])) {
                $this-&gt;addNewWebsiteLogin($request, Player::where('mail', $request-&gt;input('mail'))-&gt;pluck('id')-&gt;first(), "0");
                return Redirect::to('/login')-&gt;withMessage('Email and password do not match')-&gt;withColor('danger');
            }
            else {
                $this-&gt;addNewWebsiteLogin($request, Auth::user()-&gt;id, "1");

                $user = Auth::user();
                $user-&gt;last_online = time();
                $user-&gt;save();

                if (config('frontend.government_only') &amp;&amp; (Auth::Guest() || Auth::user()-&gt;roleplay-&gt;government_id == 0)) {
                    Auth::logout();
                    return Redirect::to('/login')-&gt;withMessage(config('frontend.site_name') . ' is only open to government individuals at this moment, too bad.')-&gt;withColor('danger');
                }

                return Redirect::to('/home')-&gt;withMessage('Welcome back!');
            }
        }
    }

    private function addNewWebsiteLogin(Request $request, $userId, $status) {
        $websiteLogin                    = new WebsiteLogin;
        $websiteLogin-&gt;user_id           = $userId;
        $websiteLogin-&gt;request_ip        = $request-&gt;ip();
        $websiteLogin-&gt;request_system    = 'TODO';
        $websiteLogin-&gt;request_browser   = 'TODO';
        $websiteLogin-&gt;login_status      = $status;
        $websiteLogin-&gt;save();
    }
}
You can use Laravel's form requests to keep rules and validation logic out of controllers.