View pdf files in Laravel

2

I have pdf files already uploaded to the server, I load them in a list and I want to be able to show them to the user, but for all the links it always shows me the first one I went up.

What I send from the controller:

public function index()
{
    $documentos = Documento::paginate();
    return view('Documentos.index',compact('documentos'));
}

What the view shows:

    <table class="table">
    <thead class="text-center">
        <tr class="row">
            <th class="col-md-3">Titulo</th>
            <th class="col-md-2" colspan="2">Acciones</th>
        </tr>
    </thead>
    <tbody>
        @foreach ($documentos as $item)
            <tr class="row">
                <td class="col-md-3 text-center">{{ $item->titulo }}</td>
                <td class="col-md-2 text-center">
                    <a class="btn btn-sm btn-success" title="Ver documento" data-toggle="modal" data-target=".bd-example-modal-lg">Mostrar PDF</a>
                </td>
            </tr>
            {{-- Modal --}}
            <div class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <embed src="{{asset('archivos/'.$item->ruta)}}">
                    </div>
                </div>
            </div>
        @endforeach
    </tbody>
</table>

Only the first document that I uploaded in all the links loads, where I should show different documents. Help community.

    
asked by Jluis Antares 29.09.2018 в 17:36
source

1 answer

0

You can use the pagination by passing a parameter to it and passing it the $ documents variable:

public function index() {
    $documentos = Documento::paginate(10);
    return view('Documentos.index')->with('documentos', $documentos);
}

And that's how ten elements would look

    
answered by 17.10.2018 в 03:53