mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-16 09:44:06 +00:00
Consolidate single-action controllers into resource controllers
Merge 11 single-action controllers into their parent resource controllers: - Invoice: send, sendPreview, clone, changeStatus -> InvoicesController - Estimate: send, sendPreview, clone, convertToInvoice, changeStatus -> EstimatesController - Payment: send, sendPreview -> PaymentsController Extract clone and convert business logic from controllers into services: - InvoiceService: add clone(), changeStatus() - EstimateService: add clone(), convertToInvoice(), changeStatus() Previously this logic was inlined in controllers (~80-90 lines each).
This commit is contained in:
@@ -5,11 +5,13 @@ namespace App\Http\Controllers\V1\Admin\Payment;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\DeletePaymentsRequest;
|
||||
use App\Http\Requests\PaymentRequest;
|
||||
use App\Http\Requests\SendPaymentRequest;
|
||||
use App\Http\Resources\PaymentResource;
|
||||
use App\Models\Payment;
|
||||
use App\Services\PaymentService;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Mail\Markdown;
|
||||
|
||||
class PaymentsController extends Controller
|
||||
{
|
||||
@@ -88,4 +90,25 @@ class PaymentsController extends Controller
|
||||
'success' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function send(SendPaymentRequest $request, Payment $payment)
|
||||
{
|
||||
$this->authorize('send payment', $payment);
|
||||
|
||||
$response = $this->paymentService->send($payment, $request->all());
|
||||
|
||||
return response()->json($response);
|
||||
}
|
||||
|
||||
public function sendPreview(Request $request, Payment $payment)
|
||||
{
|
||||
$this->authorize('send payment', $payment);
|
||||
|
||||
$markdown = new Markdown(view(), config('mail.markdown'));
|
||||
|
||||
$data = $this->paymentService->sendPaymentData($payment, $request->all());
|
||||
$data['url'] = $payment->paymentPdfUrl;
|
||||
|
||||
return $markdown->render('emails.send.payment', ['data' => $data]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user