how to make a simple view of a column in laravel?

0

good I am currently doing an application of a library in laravel in which I use a foreach to show the values of the books table in the following way:

@foreach($libros as $libro)

<img src="libreria/app/{{$libro->path}}" alt="" />
</div>
<a class="span" href="ver"> 
<i>{{$libro->titulo}}</i></a>
<p class="info">IDIOMA:&nbsp;&nbsp;{{$libro->idioma}}</p>
<p class="info">PAGINAS:&nbsp;&nbsp;{{$libro->paginas}}</p>
<p class="info">CATEGORIA:&nbsp;&nbsp;{{$libro->categoria}}</p>
<p class="info">VOLUMENES DISPONIBLES:&nbsp;&nbsp; {{$libro->cantidad}}</p>
</div>

My question is how can I make an individual view of each column that I send to the "see" method to the one that is sending each column?

    
asked by Santiago Avila 28.01.2017 в 20:12
source

1 answer

0

Creating a subview, something quick would be like this:

@foreach($libros as $libro)

  <img src="libreria/app/{{$libro->path}}" alt="" />
    </div>
    <a class="span" href="ver"> 
    <i>{{$libro->titulo}}</i></a>
    @include('ver', ['libro' => $libro, 'texto' => 'IDIOMA'])
    @include('ver', ['libro' => $libro, 'texto' => 'PAGINAS'])
    @include('ver', ['libro' => $libro, 'texto' => 'CATEGORIAS'])
    @include('ver', ['libro' => $libro, 'texto' => 'VOLUMENES'])
    </div>

ver.blade.php

<p class="info">{{$texto}}:&nbsp;&nbsp;{{$libro->idioma}}</p>

Surely you can improve the code to not make it so redundant when including subviews, but this gives you the idea of how to solve the problem.

    
answered by 28.01.2017 в 20:27