Laravel 5.2 conditional extends template in Blade
The first line in your extended blade view must be the @extends
directive.
Try using a ternary operator for this.
@extends(isset(Auth::user()->id) ? 'layouts.adminlayout' : 'layouts.default');
UPDATE for role based layouts. Refer to this question for more conditions.
@extends((!isset(Auth::user()->id))? 'layouts.default': ((Auth::user()->role == 'admin') ? 'layouts.adminlayout' : 'layouts.moderatorlayout'));