How to set HTML attribute with @Yield() in Laravel?

Asked

Viewed 227 times

0

I’m trying to create a template for my control panel in Laravel.

I want the top right corner to have a BACK button, where I can set the link with the @yield

I tried to make the following code, but I was unsuccessful, it shows as if the href was blank

// layouts.master.blade.php
<a href="@yield('voltar')">Voltar</a>

and on the extended page

// usuario.editar.php
@extends('../layouts.master')

@section('voltar')
    dashboard
@stop

1 answer

1


Assuming dashboard is the name of your route, you need to convert to a valid url before returning to the href.

Try the following:

@extends('../layouts.master')

@section('voltar')
    link_to_route('dashboard')
@stop

More information on documentation of the Laravel

Browser other questions tagged

You are not signed in. Login or sign up in order to post.