public static function attempt($input)
    {
        $userModel = Config::get('user');
        $model = new $userModel();

        $count = 0;

        foreach ($input as $field => $value) {
            if ($field == '_') {
                unset($input[$field]);
            } else {
                $count++;
            }
            if ($count == 1) {
                $primary = $field;
            }
        }

        if (!empty($input)) {
            $user = $model->where($primary, $input[$primary])->first();

            if (! empty($user) && Hash::check($input['password'], $user->password)) {
                Session::set('user', $user->id);
                return true;
            }

            return false;
        }
    }
public static function attempt($input)
    {
        $userModel = Config::get('user');
        $model = new $userModel();

        $count = 0;

        foreach ($input as $field => $value) {
            if ($field == '_') {
                unset($input[$field]);
            } else {
                $count++;
            }
            if ($count == 1) {
                $primary = $field;
            }
        }

        if (!empty($input)) {
            $user = $model->where($primary, $input[$primary])->first();

            if (! empty($user) && Hash::check($input['password'], $user->password)) {
                Session::set('user', $user->id);
                return true;
            }

            return false;
        }
    }
public static function attempt ( $ input ) { $ userModel = Config :: get ( 'user' ) ; $ model = new $ userModel ( ) ; $ count = 0 ; foreach ( $ input as $ field => $ value ) { if ( $ field == '_' ) { unset ( $ input [ $ field ] ) ; } else { $ count ++ ; } if ( $ count == 1 ) { $ primary = $ field ; } } if ( ! empty ( $ input ) ) { $ user = $ model -> where ( $ primary , $ input [ $ primary ] ) -> first ( ) ; if ( ! empty ( $ user ) && Hash :: check ( $ input [ 'password' ] , $ user -> password ) ) { Session :: set ( 'user' , $ user -> id ) ; return true ; } return false ; } }
Attempt to login the user.
If succeeds, create a user session.

@param $input
@return bool
Attempt to login the user . If succeeds create a user session .