Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

birdietorerik's avatar

Header may not contain more than a single header, new line detected

Hi!

Get this error when login

Header may not contain more than a single header, new line detected

This is my LoginController

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Auth;
use App\Models\Role;
use App\Models\User;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */

    use AuthenticatesUsers;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo;

    public function redirectTo()
    {
        // Check if more then one role
        // If only 1 role, no need to select role
        $userid = auth()->user()->id;
        $roles = Role::getroles($userid);
 
        $numbroles =$roles->count();
        
        if($numbroles>1) {
            return 'roller';
        } else {

        $role_id = User::getDefaultRole();

        switch ($role_id) {
            case 1:
                return redirect('admin/dashboard');
              break;
            case 2:
                return redirect('admin/dashboard');
              break;
            case 3:
                return redirect('admin/dashboard');
              break;
            case 4:
                return redirect('admin/dashboard');
              break;
            case 5:
                return redirect('admin/dashboard');
              break;
            case 6:
                return redirect('admin/dashboard');
              break;
            case 7:
                return redirect('admin/dashboard');
              break;
            case 8:
                return redirect('admin/dashboard');
              break;
            case 9:
                return redirect('admin/player');
              break;
            default:
               return redirect('admin/player');
          }
        }
    } 

    /**
     * Create a new controller instance.
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

    /**
     * The user has logged out of the application.
     *
     * @return mixed
     */
    protected function loggedOut(Request $request)
    {
        if ($request->wantsJson()) {
            return response(null, Response::HTTP_NO_CONTENT);
        }
    }
}

Cant figer out the problem ?

0 likes
0 replies

Please or to participate in this conversation.