In the app.blade.php file I have the following code inside the "body" tag:
style="background-image: url('fondos/fondo.jpg')"
This will be inherited in other views and will make all views have this image, as in this:
@extends('layouts.app')
@section('content')
<div class="row col-md-8 col-md-offset-2">
<div align="center" class="panel panel-default">
<div class="panel-heading">
<h1 style="color:#9999FF;" class="text-center text-mute"> {{ __("Jardin botánico Floramania") }} </h1>
</div>
<div class="panel-body">
@Logged()
@Hueco()
<a href="formulario/rol">Elegir rol</a>
@endHueco
<a class="pull-left" href="souvenirs">
@Cliente()
Tienda Online
@endCliente
@Administrador()
Lista de Souvenirs
@endAdministrador
</a>
@Cliente()
<a class="pull-right" href="formulario/saldo">Realizar un ingreso</a>
@if(is_null(Auth::user()->saldo)==false)
<h4 style="color:#55AADD" class="pull-center">Saldo actual: {{Auth::user()->saldo}}€</h4><br>
<a class="pull-left" href="entrada/{{Auth::user()->id}}">Ver tus entradas</a>
<r class="pull-center">
@if(Auth::user()->saldo>=7)
<a href="formulario/entrada">Comprar entrada (7€)</a>
@else
<i style="color:#0000FF">Necesitas 7€ para comprar una entrada</i>
@endif
</r>
@endif
@endCliente
@Administrador()
<a class="pull-right" href="entrada">Lista de entradas</a><br><br>
<a class="pull-left" href="formulario/plantas">Crear una nueva planta</a>
@endAdministrador
@Legal()
@if(Auth::user()->rol=='administrador' || is_null(Auth::user()->saldo)==false)
<a href="clientela" class="pull-right">Lista de usuarios</a>
@endif
@endLegal
@include('partials.errors')
@else
<p style="color:#0000FF">Inicia sesión para realizar operaciones</p>
@endLogged
</div>
</div>
@forelse($planta as $plantas)
<div class="panel panel-default">
<div class="panel-heading">
<h3>
<a href="comentarios/{{ $plantas->id }}">{{ $plantas->nombre }}</a>
@Administrador()
<a href="borrar/{{ $plantas->id }}" class="btn btn-danger pull-right">Eliminar planta</a>
<a href="modificar/{{ $plantas->id }}" class="btn btn-info pull-right">Modificar planta</a>
@endAdministrador
</h3>
</div>
<div class="panel-body">
<h4>{{ $plantas->descripcion }}</h4>
@if($plantas->foto)
<img src="{{ $plantas->rutas() }}" style="width: 200px; height: 200px; border: 2px solid green" class="img-responsive img-rounded" />
@endif
</div>
<div class="panel-body">
<b>Tamaño:</b> {{ $plantas->tamaño }}<br>
<b>Flor:</b> {{ $plantas->flor }}<br>
<b>Hoja:</b> {{ $plantas->hoja }}<br>
<span class="pull-right"> {{ __("Comentarios") }}: {{ $plantas->comentarios->count() }} </span>
</div>
</div>
@empty
<div class="alert alert-danger">
{{ __("No hay ninguna planta en este momento") }}
</div>
@endforelse
</div>
@endsection
However, I find that this is not always the case, as in this example:
@extends('layouts.app')
@section('content')
<div class="row">
<div align="center" class="col-md-8 col-md-offset-2">
<div class="panel panel-heading">
<h2 style="color:#0088FF;" class="text-center text-mute"> {{ __("Comentarios acerca del :nombre", ['nombre' => $plantas->nombre]) }} </h2>
</div>
@forelse($comentario as $c)
<div class="panel panel-default">
<div class="panel-heading panel-heading-forum">
<h3>
Escrito por {{$c->usuario->name}}
@Logged()
@if(Auth::user()->id==$c->usuario->id && $c->comentario!="Comentario Eliminado")
<a href="../cambiar/{{ $c->id }}" class="btn btn-danger pull-right">Borrar el comentario</a>
@endif
@endLogged
</h3>
</div>
<div class="panel-body">
{{ $c->comentario }}
</div>
</div>
@empty
<div class="alert alert-danger">
{{ __("No hay ningún comentario sobre esta planta actualmente") }}
</div>
@endforelse
@Logged()
@include('partials.errors')
<form method="POST" action="../comentario">
{{ csrf_field() }}
<input type="hidden" name="planta" value="{{ $plantas->id }}"/>
<div class="form-group">
<label for="comentario" class="col-md-12 control-label"> {{ __("Escribe un comentario...") }}
</label>
<input id="comentario" class="form-control" name="comentario" value="{{ old('comentario') }}"/>
</div>
<button type="submit" name="addComentario" class="btn btn-default"> {{ __("Añadir Comentario") }}
</button>
</form>
@else
<h6 style="color:#0000FF;" class="text-center text-mute">(Tienes que iniciar sesión si quieres escribir comentarios)</h6>
@endLogged
</div>
</div>
@endsection
What will I be doing wrong in the second case?
More information. I have tried to put the following code in the head of app.blade.php:
@stack('styles')
Once this is done, I have modified my two examples so that they only have this code:
@extends('layouts.app')
@section('content')
@push('styles')
<body style="background-image: url('fondos/fondo.jpg');"/>
@endpush
@endsection
To my surprise, even though the code is exactly the same in both cases, my image still appears in the first example, but in the second one it does not.
Both views are located in \ resources \ views \ vegetal. The first is index.blade and the second detail.blade .