Support the ongoing development of Laravel.io →
Authentication
Last updated 3 months 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('[email protected]');
  }else {
      return Redirect::action('[email protected]');
  }
});

Let me know if this helps.

Last updated 3 months 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 4 years ago.
0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Moderators

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

Your logo here?

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

© 2022 Laravel.io - All rights reserved.