dongshi4078 2017-03-24 05:00
浏览 285

Laravel:如何在make:auth之后不要求登录

I just ran php artisan make:auth on my app which made it so that nothing can be accessed on the app without logging in.

I want some content to be visible to guest users, but don't know how. Let's say I just want them to be able to see the home page, the page they get directed to when they go to localhost:8000, instead of being instantly redirected to the localhost:8000/login page. How do I do this?

  • 写回答

1条回答 默认 最新

  • dongyi1524 2017-03-24 06:17
    关注

    You may add guest access within a specific controller, like so:

    public function __construct()
    {
        $this->middleware('guest', [ 'except' => 'logout' ]);
    }
    

    in the example above, all functions in the controller are accessible to guests except logout, for which you must be logged in.

    or within a router:

    Route::group(['middleware' => 'guest'], function(){
        Route::get(...
    });
    Route::get('/', 'HomeController@index')->name('home')->middleware('guest');
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示