Laravel: Extending different layouts inside if-els

2019-07-17 03:52发布

I'm trying to extend different layouts inside if-else statement. Here is my code:

@if(Auth::check())
    @extends('layouts.adminPanel')
@else
    @extends('layouts.home')
@endif

But the view files extending both layouts. No matter user logged in or not!

How can I fix it?

1条回答
The star\"
2楼-- · 2019-07-17 04:19

Add Extends at the first line

@extends(\Auth::check() ? 'layouts.adminPanel' : 'layouts.home')
查看更多
登录 后发表回答