Broken link in blade view

0

I have the layout parent of the application that contains the sidebar and top (the menus of all life), but I have the problem that in some templates .blade.php the links do not always work, I expose my problem:

I have this app.blade.php view that the main one:

                <li class="dropdown dropdown-user nav-item">
                    <a href="" data-toggle="dropdown" class="dropdown-toggle nav-link dropdown-user-link">
                        <span class="avatar avatar-online">
                            <img src="{{ URL::asset('images/portrait/small/avatar-s-1.png')}}" alt="avatar"><i>
                            </i>
                        </span>
                        <span class="user-name">{{ Auth::user()->name }}</span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-right">
                         <a href="{{ url('/worker/show/' . Crypt::encrypt(Auth::user()->id)) }}" class="dropdown-item" >
                       <!--<a href="{{ url('/worker/show/.Crypt::encrypt(Auth::user()->id)') }}" class="dropdown-item">-->
                            <i class="icon-head"></i> Editar Perfil</a>
                        <a href="#" class="dropdown-item"><i class="icon-mail6"></i> Correo</a>
                        <a href="#" class="dropdown-item"><i class="icon-clipboard2"></i> Tareas</a>
                        <a href="{{url('/home')}}" class="dropdown-item"><i class="icon-calendar5"></i> Calender</a>
                        <div class="dropdown-divider"></div>
                        <a href="{{url('/logout')}}" class="dropdown-item"><i class="icon-power3"></i>Salir</a>
                    </div>
                </li>

As you can see I have a drop-down menu in which I have links to some parts of the web. However, when for example I'm in the home, (which extends from app.blade.php) is not even deployed, and it happens the same only in 2 or 3 more views. And they perfectly extend all the same: Layout son:

extends('layouts.app')

<link rel="stylesheet" href="{{ URL::asset('css/plugins/calendars/fullcalendar.min.css')}}"/>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.2.7/fullcalendar.print.css" media="print"/>

@section('content')
   codigo html....
@stop 

@section('javascript')

@stop

I can put the code of the whole view but basically it is a copy and paste of this Could you explain me why this happens?

Thanks in advance. Greetings.

    
asked by Peisou 06.08.2018 в 17:50
source

1 answer

0

Try changing the way you call the routes from url ('route') to route ('as') .

For example, in:

<a href="{{url('/home')}}" class="dropdown-item"><i class="icon-calendar5"></i> Calender</a>
<div class="dropdown-divider"></div>
<a href="{{url('/logout')}}" class="dropdown-item"><i class="icon-power3"></i>Salir</a>

you change it for:

<a href="{{route('home')}}" class="dropdown-item"><i class="icon-calendar5"></i> Calender</a>
<div class="dropdown-divider"></div>
<a href="{{route('logout')}}" class="dropdown-item"><i class="icon-power3"></i>Salir</a>

Where the as , is the one you declare on the route something this way 'as' = > 'home'

Route::get('/home', ['uses'=>'tuControladorController@home','as' => 'home']);

With this you make sure you call the exact route you want

    
answered by 06.08.2018 в 21:53