app/Http/Controllers/AuthenticationController.php
/**
     * Validate user and assign role.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Validate user and assign role.
Validate user and assign role .
public function check(Request $request)
    {
        $rules = array(
                'email' =>'required|email',
                'password' => 'required'
        );
        $validator = Validator::make($request->all(), $rules);
        if ($validator->fails()) return redirect('/signin')->withErrors($validator , 'auth');
        $email = $request->input('email');
        $password = $request->input('password');
        if(Auth::attempt(['email' => $email, 'password' => $password, 'active' => 1 ,'isAdmin' => 0] )){
            $user = Auth::user();
            if($user->role == 1) return redirect()->intended('/booking?role=guest');
            return redirect()->intended('/booking');
        }
       return redirect()->intended('/signin')->withErrors('อีเมลหรือรหัสผ่านไม่ถูกต้อง');
    }
public function check ( Request $ request ) { $ rules = array ( 'email' => 'required|email' , 'password' => 'required' ) ; $ validator = Validator :: make ( $ request -> all ( ) , $ rules ) ; if ( $ validator -> fails ( ) ) return redirect ( '/signin' ) -> withErrors ( $ validator , 'auth' ) ; $ email = $ request -> input ( 'email' ) ; $ password = $ request -> input ( 'password' ) ; if ( Auth :: attempt ( [ 'email' => $ email , 'password' => $ password , 'active' => 1 , 'isAdmin' => 0 ] ) ) { $ user = Auth :: user ( ) ; if ( $ user -> role == 1 ) return redirect ( ) -> intended ( '/booking?role=guest' ) ; return redirect ( ) -> intended ( '/booking' ) ; } return redirect ( ) -> intended ( '/signin' ) -> withErrors ( 'อีเมลหรือรหัสผ่านไม่ถูกต้อง'); }
Validate user and assign role.
Validate user and assign role .
//var_dump(Auth::user());