mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-27 11:41:09 -04:00
Added preview to invoice, estimate & payment pdfs
This commit is contained in:
@ -4,6 +4,7 @@ namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Estimate;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class EstimatePdfController extends Controller
|
||||
{
|
||||
@ -13,8 +14,13 @@ class EstimatePdfController extends Controller
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Estimate $estimate)
|
||||
public function __invoke(Request $request, Estimate $estimate)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return $estimate->getPDFData();
|
||||
}
|
||||
|
||||
|
||||
return $estimate->getGeneratedPDFOrStream('estimate');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class InvoicePdfController extends Controller
|
||||
{
|
||||
@ -13,8 +14,12 @@ class InvoicePdfController extends Controller
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Invoice $invoice)
|
||||
public function __invoke(Request $request, Invoice $invoice)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return $invoice->getPDFData();
|
||||
}
|
||||
|
||||
return $invoice->getGeneratedPDFOrStream('invoice');
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Payment;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PaymentPdfController extends Controller
|
||||
{
|
||||
@ -13,8 +14,12 @@ class PaymentPdfController extends Controller
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Payment $payment)
|
||||
public function __invoke(Request $request, Payment $payment)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return view('app.pdf.payment.payment');
|
||||
}
|
||||
|
||||
return $payment->getGeneratedPDFOrStream('payment');
|
||||
}
|
||||
}
|
||||
|
||||
@ -412,6 +412,10 @@ class Estimate extends Model implements HasMedia
|
||||
'taxes' => $taxes,
|
||||
]);
|
||||
|
||||
if (request()->has('preview')) {
|
||||
return view('app.pdf.estimate.'.$estimateTemplate);
|
||||
}
|
||||
|
||||
return PDF::loadView('app.pdf.estimate.'.$estimateTemplate);
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ class Invoice extends Model implements HasMedia
|
||||
|
||||
public const STATUS_DRAFT = 'DRAFT';
|
||||
public const STATUS_SENT = 'SENT';
|
||||
public const STATUS_OVERDUE = 'OVERDUE';
|
||||
public const STATUS_VIEWED = 'VIEWED';
|
||||
public const STATUS_COMPLETED = 'COMPLETED';
|
||||
|
||||
@ -575,6 +576,10 @@ class Invoice extends Model implements HasMedia
|
||||
'taxes' => $taxes,
|
||||
]);
|
||||
|
||||
if (request()->has('preview')) {
|
||||
return view('app.pdf.invoice.'.$invoiceTemplate);
|
||||
}
|
||||
|
||||
return PDF::loadView('app.pdf.invoice.'.$invoiceTemplate);
|
||||
}
|
||||
|
||||
|
||||
@ -375,6 +375,10 @@ class Payment extends Model implements HasMedia
|
||||
'logo' => $logo ?? null,
|
||||
]);
|
||||
|
||||
if (request()->has('preview')) {
|
||||
return view('app.pdf.payment.payment');
|
||||
}
|
||||
|
||||
return PDF::loadView('app.pdf.payment.payment');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user