mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Rename controller namespaces: drop V1 prefix, clarify roles
V1/Admin -> Company (company-scoped controllers) V1/SuperAdmin -> Admin (platform-wide admin controllers) V1/Customer -> CustomerPortal (customer-facing portal) V1/Installation -> Setup (installation wizard) V1/PDF -> Pdf (consistent casing) V1/Modules -> Modules (drop V1 prefix) V1/Webhook -> Webhook (drop V1 prefix) The V1 prefix served no purpose - API versioning is in the route prefix (/api/v1/), not the controller namespace. "Admin" was misleading for company-scoped controllers. "SuperAdmin" is now simply "Admin" for platform administration.
This commit is contained in:
24
app/Http/Controllers/Pdf/DownloadInvoicePdfController.php
Normal file
24
app/Http/Controllers/Pdf/DownloadInvoicePdfController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Invoice;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class DownloadInvoicePdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Invoice $invoice)
|
||||
{
|
||||
$path = storage_path('app/temp/invoice/'.$invoice->id.'.pdf');
|
||||
|
||||
return response()->download($path);
|
||||
}
|
||||
}
|
||||
24
app/Http/Controllers/Pdf/DownloadPaymentPdfController.php
Normal file
24
app/Http/Controllers/Pdf/DownloadPaymentPdfController.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class DownloadPaymentPdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Payment $payment)
|
||||
{
|
||||
$path = storage_path('app/temp/payment/'.$payment->id.'.pdf');
|
||||
|
||||
return response()->download($path);
|
||||
}
|
||||
}
|
||||
39
app/Http/Controllers/Pdf/DownloadReceiptController.php
Normal file
39
app/Http/Controllers/Pdf/DownloadReceiptController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Expense;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DownloadReceiptController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param string $hash
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function __invoke(Expense $expense)
|
||||
{
|
||||
$this->authorize('view', $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',
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
app/Http/Controllers/Pdf/EstimatePdfController.php
Normal file
30
app/Http/Controllers/Pdf/EstimatePdfController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Estimate;
|
||||
use App\Services\EstimateService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class EstimatePdfController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EstimateService $estimateService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Request $request, Estimate $estimate)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return $this->estimateService->getPdfData($estimate);
|
||||
}
|
||||
|
||||
return $estimate->getGeneratedPDFOrStream('estimate');
|
||||
}
|
||||
}
|
||||
30
app/Http/Controllers/Pdf/InvoicePdfController.php
Normal file
30
app/Http/Controllers/Pdf/InvoicePdfController.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Invoice;
|
||||
use App\Services\InvoiceService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class InvoicePdfController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly InvoiceService $invoiceService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Request $request, Invoice $invoice)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return $this->invoiceService->getPdfData($invoice);
|
||||
}
|
||||
|
||||
return $invoice->getGeneratedPDFOrStream('invoice');
|
||||
}
|
||||
}
|
||||
25
app/Http/Controllers/Pdf/PaymentPdfController.php
Normal file
25
app/Http/Controllers/Pdf/PaymentPdfController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Pdf;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Payment;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class PaymentPdfController extends Controller
|
||||
{
|
||||
/**
|
||||
* Handle the incoming request.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Request $request, Payment $payment)
|
||||
{
|
||||
if ($request->has('preview')) {
|
||||
return view('app.pdf.payment.payment');
|
||||
}
|
||||
|
||||
return $payment->getGeneratedPDFOrStream('payment');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user