Necesito generar un archivo .pdf con dompdf pero no me genera nada cuando presiono el boton.
Mi PDFController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Product;
use PDF;
class PDFController extends Controller
{
public function pdf(Request $request){
$products=Product::all();
view()->share('products', $products);
if ($request->has('descargar')) {
$pdf = PDF::loadView('cart.index');
return $pdf->download('cotizacion');
}
return view('cart.index');
}
}
Vista que deseo generar en PDF, al final llamo a la ruta en el ultimo boton, index.blade.php
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>qty</th>
<th>size</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach(Cart::content() as $cartItem)
<tr>
<td>{{$cartItem->name}}</td>
<td>{{$cartItem->price}}</td>
<td width="50px">
{!! Form::open(['route' => ['cart.update',$cartItem->rowId], 'method' => 'PUT']) !!}
<input name="qty" type="text" value="{{$cartItem->qty}}">
</td>
<td>
<div > {!! Form::select('size', ['small'=>'Small','medium'=>'Medium','large'=>'Large'] , $cartItem->options->has('size')?$cartItem->options->size:'' ) !!}
</div>
</td>
<td>
<input style="float: left" type="submit" class="button success small" value="Ok">
{!! Form::close() !!}
<form action="{{route('cart.destroy',$cartItem->rowId)}}" method="POST">
{{csrf_field()}}
{{method_field('DELETE')}}
<input class="button small alert" type="submit" value="Delete">
</form>
</td>
</tr>
@endforeach
<tr>
<td></td>
<td>
Tax: ${{Cart::tax()}} <br>
Sub Total: $ {{Cart::subtotal()}} <br>
Grand Total: $ {{Cart::total()}}
</td>
<td>Items: {{Cart::count()}}
</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<a href="{{route('checkout.shipping')}}" class="button">Checkout</a>
<a href="{{route('pdf')}}" class="button small alert">Import to PDF</a>
</div>
@extends('layouts.main')
@section('content')
<div class="row">
<h3>Cart Items</h3>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>qty</th>
<th>size</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach(Cart::content() as $cartItem)
<tr>
<td>{{$cartItem->name}}</td>
<td>{{$cartItem->price}}</td>
<td width="50px">
{!! Form::open(['route' => ['cart.update',$cartItem->rowId], 'method' => 'PUT']) !!}
<input name="qty" type="text" value="{{$cartItem->qty}}">
</td>
<td>
<div > {!! Form::select('size', ['small'=>'Small','medium'=>'Medium','large'=>'Large'] , $cartItem->options->has('size')?$cartItem->options->size:'' ) !!}
</div>
</td>
<td>
<input style="float: left" type="submit" class="button success small" value="Ok">
{!! Form::close() !!}
<form action="{{route('cart.destroy',$cartItem->rowId)}}" method="POST">
{{csrf_field()}}
{{method_field('DELETE')}}
<input class="button small alert" type="submit" value="Delete">
</form>
</td>
</tr>
@endforeach
<tr>
<td></td>
<td>
Tax: ${{Cart::tax()}} <br>
Sub Total: $ {{Cart::subtotal()}} <br>
Grand Total: $ {{Cart::total()}}
</td>
<td>Items: {{Cart::count()}}
</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<a href="{{route('checkout.shipping')}}" class="button">Checkout</a>
<a href="{{route('pdf')}}" class="button small alert">Import to PDF</a>
</div>
@endsection
Mi ruta, web.php
Route::get('/pdf', 'PDFController@pdf')->name('pdf');