mirror of
https://github.com/crater-invoice/crater.git
synced 2025-10-28 04:01:10 -04:00
v5.0.0 update
This commit is contained in:
22
app/Http/Controllers/V1/PDF/DownloadInvoicePdfController.php
Normal file
22
app/Http/Controllers/V1/PDF/DownloadInvoicePdfController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Invoice;
|
||||
|
||||
class DownloadInvoicePdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Invoice $invoice)
|
||||
{
|
||||
$path = storage_path('app/temp/invoice/'.$invoice->id.'.pdf');
|
||||
|
||||
return response()->download($path);
|
||||
}
|
||||
}
|
||||
22
app/Http/Controllers/V1/PDF/DownloadPaymentPdfController.php
Normal file
22
app/Http/Controllers/V1/PDF/DownloadPaymentPdfController.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Payment;
|
||||
|
||||
class DownloadPaymentPdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Payment $payment)
|
||||
{
|
||||
$path = storage_path('app/temp/payment/'.$payment->id.'.pdf');
|
||||
|
||||
return response()->download($path);
|
||||
}
|
||||
}
|
||||
37
app/Http/Controllers/V1/PDF/DownloadReceiptController.php
Normal file
37
app/Http/Controllers/V1/PDF/DownloadReceiptController.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Expense;
|
||||
|
||||
class DownloadReceiptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Expense $expense
|
||||
* @param string $hash
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Expense $expense)
|
||||
{
|
||||
if ($expense) {
|
||||
$media = $expense->getFirstMedia('receipts');
|
||||
if ($media) {
|
||||
$imagePath = $media->getPath();
|
||||
$response = \Response::download($imagePath, $media->file_name);
|
||||
if (ob_get_contents()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'error' => 'receipt_not_found',
|
||||
]);
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/V1/PDF/EstimatePdfController.php
Normal file
20
app/Http/Controllers/V1/PDF/EstimatePdfController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Estimate;
|
||||
|
||||
class EstimatePdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Estimate $estimate)
|
||||
{
|
||||
return $estimate->getGeneratedPDFOrStream('estimate');
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/V1/PDF/InvoicePdfController.php
Normal file
20
app/Http/Controllers/V1/PDF/InvoicePdfController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Invoice;
|
||||
|
||||
class InvoicePdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Invoice $invoice)
|
||||
{
|
||||
return $invoice->getGeneratedPDFOrStream('invoice');
|
||||
}
|
||||
}
|
||||
20
app/Http/Controllers/V1/PDF/PaymentPdfController.php
Normal file
20
app/Http/Controllers/V1/PDF/PaymentPdfController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Controllers\V1\PDF;
|
||||
|
||||
use Crater\Http\Controllers\Controller;
|
||||
use Crater\Models\Payment;
|
||||
|
||||
class PaymentPdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Payment $payment)
|
||||
{
|
||||
return $payment->getGeneratedPDFOrStream('payment');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user