Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

Your filter is actually pretty close, take the auth filter for example:

Route::filter('auth', function()
{
  if (Auth::guest()) return Redirect::guest('login');
});

Here we see the auth filter checking if the user is a guest or not, and if true, the filter redirects the user to a 'login' page.

We can add filter with similar logic to achieve what you want.

Route::filter('<whatever filter name here>', function()
{
  if (Auth::guest())
  { 
      return Redirect::action('PagesController@home');
  }else {
      return Redirect::action('DashController@index');
  }
});

Let me know if this helps.

Last updated 2 years ago.
0

I had the same issue and solved it using a ternary. In one view I also had to set some variables, which previously had been part of the extend, so I just moved it up.

<?php
$title = 'FAQ';
$active_menu_item =  'FAQ';
?>
@extends(Auth::user() ? 'layouts.app' : 'layouts.main')
Last updated 6 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.