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;
        }
    }