title: Laravel 5 - Redirect To URL After Registration
body: <p>have multiple users with totally different post login panels. One for teachers and other for students. I made middlewares to separate their views. Middleware checks if a property ( column in database ) named entity is 'student' or 'company' and restricts or permits views accordingly. And yes Guest isnt permitted to either of the post login panel.</p>
  
  <p>I am using same table to save logins. (entity column differentiates if its a teacher or student). Now I want to redirect the users to different views. If I alter <code>$redirectTo = "/studentPanel"</code>. Middleware acts and teacher login cannot access this . But if I hard code <code>$redirectTo = "/teacherPanel"</code> , then student post login panel is not accesible.</p>
  
  <p>How can set <code>$redirectTo</code> dynamically . I thought of setting in construct method of auth controller.</p>
  
  <p>Tried this:</p>
  
  <pre><code>public function __construct(Request $request ) {
  
  $this-&gt;middleware('guest', ['except' =&gt; 'getLogout']);
  
  if(Auth::user() &amp;&amp; $request-&gt;user()-&gt;isStudent() )
      $this-&gt;redirectTo = "/studentPanel";
  elseif(Auth::user() &amp;&amp; $request-&gt;user()-&gt;isTeacher() )
      $this-&gt;redirectTo = "/teacherPanel";
  else
        $this-&gt;redirectTo = "/auth/login";
  </code></pre>
  
  <p>}</p>
  
  <p>Here <code>isStudent()</code> and isCompany are functions in App\User which respond with true or false checking the entity column value in Database.</p>
  
  <p>I thought this way and I am getting error <code>"Call to a member function isStudent() on a non-object"</code></p>