agent icon indicating copy to clipboard operation
agent copied to clipboard

Blade with desktop extending layout

Open EggIt opened this issue 5 years ago • 1 comments

Hi,

I got a blade file as follows:

@if((new \Jenssegers\Agent\Agent())->isDesktop())
    @extends('layouts.app')

    @section('content')
        <h1>DESKTOP VERSION</h1>
    @endsection
@endif
@if((new \Jenssegers\Agent\Agent())->isMobile())
    <h1>MOBILE VERSION</h1>
@endif

The h1 tags are working as expected, on desktop it shows DESKTOP VERSION and on mobile it shows MOBILE VERSION.

But the same layout layouts.app is being rendered on both clients.

I expected the layout to be used only by the desktop, but it's being rendered on mobile too.

EggIt avatar Aug 04 '19 01:08 EggIt

Solution or Workaround?

in my layout app.blade.php, if i surround the content by a isDesktop condition it works:

layout: app.blade.php

@if((new \Jenssegers\Agent\Agent())->isDesktop())
<html>
<head><tags /></head>
<body>@section('content') @show</body>
</html>
@endif

i would have appreciated the layout to be excluded without performing this second condition inside it...

EggIt avatar Aug 04 '19 01:08 EggIt