<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Auth;
class AuthController extends Controller
{
    public function proses( Request $request ) {

    	$request->validate([

    		'email'	=> 'required',
    		'password'	=> 'required',
    	]);

    	$credential = request(['email', 'password']);
    	if ( Auth::attempt( $credential ) ) {

    		if ( Auth::user()->roleid == "admin" ) {

    			return redirect('android23/topic');

    		} else if ( Auth::user()->roleid == "teacher" ) {

                return redirect('teacher/android23/material');

    		} else {

                // student
                return redirect('android23/material');
    		}

    	} else {

    		echo "okee err";
    	}
    }
}
