Fix Laravel Pint formatting

This commit is contained in:
root
2026-06-09 00:03:03 -04:00
parent 8d4d610b82
commit b5fd4a4ca1
1414 changed files with 11317 additions and 10201 deletions
@@ -38,12 +38,14 @@ class BalanceCarryforwardController extends Controller
public function waive(CarryforwardAdjustmentRequest $request, int $carryforward): JsonResponse
{
$data = $request->validated();
return response()->json(['ok' => true, 'carryforward' => $this->service->waive($carryforward, (float) $data['amount'], $data['reason'] ?? null, optional($request->user())->id)]);
}
public function adjust(CarryforwardAdjustmentRequest $request, int $carryforward): JsonResponse
{
$data = $request->validated();
return response()->json(['ok' => true, 'carryforward' => $this->service->adjust($carryforward, (float) $data['amount'], $data['reason'] ?? null)]);
}
@@ -55,10 +57,13 @@ class BalanceCarryforwardController extends Controller
public function reportCsv(Request $request): StreamedResponse
{
$rows = $this->service->csvRows($this->service->report($request->query()));
return response()->streamDownload(function () use ($rows) {
$out = fopen('php://output', 'w');
foreach ($rows as $row) fputcsv($out, $row);
foreach ($rows as $row) {
fputcsv($out, $row);
}
fclose($out);
}, 'carryforward_report_' . date('Ymd_His') . '.csv', ['Content-Type' => 'text/csv']);
}, 'carryforward_report_'.date('Ymd_His').'.csv', ['Content-Type' => 'text/csv']);
}
}
@@ -143,9 +143,6 @@ class ChargeController extends BaseApiController
], $status);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -15,15 +15,24 @@ class EventChargeController extends Controller
public function index(Request $request): JsonResponse
{
$q = EventCharge::query();
foreach (['parent_id','student_id','event_id','school_year','semester'] as $field) {
if ($request->filled($field)) $q->where($field, $request->query($field));
foreach (['parent_id', 'student_id', 'event_id', 'school_year', 'semester'] as $field) {
if ($request->filled($field)) {
$q->where($field, $request->query($field));
}
}
if ($request->filled('status')) {
$status = $request->query('status');
if (Schema::hasColumn('event_charges', 'status')) $q->where('status', $status);
elseif ($status === 'paid') $q->where('event_paid', 1);
elseif ($status === 'pending') $q->where(function ($qq) { $qq->whereNull('event_paid')->orWhere('event_paid', 0); });
if (Schema::hasColumn('event_charges', 'status')) {
$q->where('status', $status);
} elseif ($status === 'paid') {
$q->where('event_paid', 1);
} elseif ($status === 'pending') {
$q->where(function ($qq) {
$qq->whereNull('event_paid')->orWhere('event_paid', 0);
});
}
}
return response()->json(['ok' => true, 'event_charges' => $q->orderByDesc('id')->paginate((int) $request->query('per_page', 25))]);
}
@@ -31,8 +40,11 @@ class EventChargeController extends Controller
{
$data = $this->normalizePayload($request->validated());
$data['created_by'] = optional($request->user())->id;
if (Schema::hasColumn('event_charges', 'status')) $data['status'] = $data['status'] ?? 'draft';
if (Schema::hasColumn('event_charges', 'status')) {
$data['status'] = $data['status'] ?? 'draft';
}
$charge = EventCharge::query()->create($data);
return response()->json(['ok' => true, 'event_charge' => $charge], 201);
}
@@ -45,6 +57,7 @@ class EventChargeController extends Controller
{
$charge = EventCharge::query()->findOrFail($eventCharge);
$charge->fill($this->normalizePayload($request->validated()))->save();
return response()->json(['ok' => true, 'event_charge' => $charge->fresh()]);
}
@@ -56,38 +69,58 @@ class EventChargeController extends Controller
public function approve(int $eventCharge): JsonResponse
{
$charge = EventCharge::query()->findOrFail($eventCharge);
if (Schema::hasColumn('event_charges', 'status')) $charge->status = 'approved';
if (Schema::hasColumn('event_charges', 'charged')) $charge->charged = 1;
if (Schema::hasColumn('event_charges', 'status')) {
$charge->status = 'approved';
}
if (Schema::hasColumn('event_charges', 'charged')) {
$charge->charged = 1;
}
$charge->save();
return response()->json(['ok' => true, 'event_charge' => $charge->fresh()]);
}
public function void(int $eventCharge): JsonResponse
{
$charge = EventCharge::query()->findOrFail($eventCharge);
if (Schema::hasColumn('event_charges', 'status')) $charge->status = 'voided';
if (Schema::hasColumn('event_charges', 'charged')) $charge->charged = 0;
if (Schema::hasColumn('event_charges', 'status')) {
$charge->status = 'voided';
}
if (Schema::hasColumn('event_charges', 'charged')) {
$charge->charged = 0;
}
$charge->save();
return response()->json(['ok' => true, 'event_charge' => $charge->fresh()]);
}
public function attachToInvoice(Request $request, int $eventCharge): JsonResponse
{
$request->validate(['invoice_id' => ['required','integer']]);
$request->validate(['invoice_id' => ['required', 'integer']]);
$charge = EventCharge::query()->findOrFail($eventCharge);
$invoiceId = (int) $request->input('invoice_id');
abort_if(!DB::table('invoices')->where('id', $invoiceId)->exists(), 404, 'Invoice not found.');
if (Schema::hasColumn('event_charges', 'invoice_id')) $charge->invoice_id = $invoiceId;
if (Schema::hasColumn('event_charges', 'status')) $charge->status = 'invoiced';
if (Schema::hasColumn('event_charges', 'charged')) $charge->charged = 1;
abort_if(! DB::table('invoices')->where('id', $invoiceId)->exists(), 404, 'Invoice not found.');
if (Schema::hasColumn('event_charges', 'invoice_id')) {
$charge->invoice_id = $invoiceId;
}
if (Schema::hasColumn('event_charges', 'status')) {
$charge->status = 'invoiced';
}
if (Schema::hasColumn('event_charges', 'charged')) {
$charge->charged = 1;
}
$charge->save();
return response()->json(['ok' => true, 'event_charge' => $charge->fresh(), 'warning' => Schema::hasColumn('event_charges','invoice_id') ? null : 'invoice_id column does not exist; charge marked as charged only.']);
return response()->json(['ok' => true, 'event_charge' => $charge->fresh(), 'warning' => Schema::hasColumn('event_charges', 'invoice_id') ? null : 'invoice_id column does not exist; charge marked as charged only.']);
}
private function normalizePayload(array $data): array
{
if (isset($data['title']) && !isset($data['event_name'])) $data['event_name'] = $data['title'];
if (isset($data['title']) && ! isset($data['event_name'])) {
$data['event_name'] = $data['title'];
}
unset($data['title'], $data['invoice_id']);
return array_filter($data, fn($v) => $v !== null);
return array_filter($data, fn ($v) => $v !== null);
}
}
@@ -16,7 +16,7 @@ class FinanceNotificationController extends Controller
public function sendPaymentReceipt(Request $request, int $payment): JsonResponse
{
$p = DB::table('payments')->where('id', $payment)->first();
abort_if(!$p, 404, 'Payment not found.');
abort_if(! $p, 404, 'Payment not found.');
$receipt = $this->service->nextReceiptNumber($p->school_year ?? date('Y'));
$log = $this->service->log([
'parent_id' => $p->parent_id ?? null,
@@ -25,34 +25,39 @@ class FinanceNotificationController extends Controller
'notification_type' => 'payment_receipt',
'channel' => 'database',
'recipient' => (string) ($p->parent_id ?? ''),
'subject' => 'Payment receipt ' . $receipt,
'subject' => 'Payment receipt '.$receipt,
], optional($request->user())->id);
return response()->json(['ok' => true, 'receipt_number' => $receipt, 'notification_log' => $log]);
}
public function sendRefundReceipt(Request $request, int $refund): JsonResponse
{
$log = $this->service->log(['refund_id' => $refund, 'notification_type' => 'refund_receipt', 'channel' => 'database', 'subject' => 'Refund receipt'], optional($request->user())->id);
return response()->json(['ok' => true, 'notification_log' => $log]);
}
public function sendInvoiceStatement(Request $request, int $invoice): JsonResponse
{
$inv = DB::table('invoices')->where('id', $invoice)->first();
abort_if(!$inv, 404, 'Invoice not found.');
abort_if(! $inv, 404, 'Invoice not found.');
$log = $this->service->log(['parent_id' => $inv->parent_id ?? null, 'invoice_id' => $invoice, 'notification_type' => 'statement_available', 'channel' => 'database', 'subject' => 'Statement available'], optional($request->user())->id);
return response()->json(['ok' => true, 'notification_log' => $log]);
}
public function sendOverdueReminder(Request $request, int $parent): JsonResponse
{
$log = $this->service->log(['parent_id' => $parent, 'notification_type' => 'overdue_balance_reminder', 'channel' => 'database', 'subject' => 'Overdue balance reminder'], optional($request->user())->id);
return response()->json(['ok' => true, 'notification_log' => $log]);
}
public function sendInstallmentReminder(Request $request, int $installment): JsonResponse
{
$log = $this->service->log(['installment_id' => $installment, 'notification_type' => 'installment_reminder', 'channel' => 'database', 'subject' => 'Installment reminder'], optional($request->user())->id);
return response()->json(['ok' => true, 'notification_log' => $log]);
}
@@ -5,10 +5,10 @@ namespace App\Http\Controllers\Api\Finance;
use App\Http\Controllers\Api\Core\BaseApiController;
use App\Http\Requests\Finance\FinancialReportRequest;
use App\Http\Requests\Finance\FinancialSummaryRequest;
use App\Http\Requests\Finance\StakeholderFinancialAnalysisRequest;
use App\Http\Requests\Finance\FinancialUnpaidParentsRequest;
use App\Http\Requests\Finance\ParentPaymentFollowUpRequest;
use App\Http\Requests\Finance\FollowUpNoteRequest;
use App\Http\Requests\Finance\ParentPaymentFollowUpRequest;
use App\Http\Requests\Finance\StakeholderFinancialAnalysisRequest;
use App\Http\Resources\Finance\FinancialReportResource;
use App\Http\Resources\Finance\FinancialSummaryResource;
use App\Http\Resources\Finance\FinancialUnpaidParentResource;
@@ -16,9 +16,9 @@ use App\Services\Finance\FinancialPdfReportService;
use App\Services\Finance\FinancialReportService;
use App\Services\Finance\FinancialSchoolYearService;
use App\Services\Finance\FinancialSummaryService;
use App\Services\Finance\StakeholderFinancialAnalysisService;
use App\Services\Finance\FinancialUnpaidParentsService;
use App\Services\Finance\ParentPaymentFollowUpService;
use App\Services\Finance\StakeholderFinancialAnalysisService;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\StreamedResponse;
@@ -82,9 +82,6 @@ class FinancialController extends BaseApiController
]);
}
public function parentPaymentFollowups(ParentPaymentFollowUpRequest $request): JsonResponse
{
return response()->json([
@@ -104,7 +101,7 @@ class FinancialController extends BaseApiController
fputcsv($out, $row);
}
fclose($out);
}, 'parent_payment_followups_' . ($report['schoolYear'] ?? 'report') . '_' . date('Ymd_His') . '.csv', ['Content-Type' => 'text/csv']);
}, 'parent_payment_followups_'.($report['schoolYear'] ?? 'report').'_'.date('Ymd_His').'.csv', ['Content-Type' => 'text/csv']);
}
public function storeParentFollowUpNote(FollowUpNoteRequest $request, int $parent): JsonResponse
@@ -118,18 +115,21 @@ class FinancialController extends BaseApiController
public function markParentContacted(FollowUpNoteRequest $request, int $parent): JsonResponse
{
$payload = array_merge($request->validated(), ['status' => $request->input('status', 'contacted')]);
return response()->json(['ok' => true, 'note' => $this->parentPaymentFollowUpService->storeNote($parent, $payload, optional($request->user())->id)], 201);
}
public function storePromiseToPay(FollowUpNoteRequest $request, int $parent): JsonResponse
{
$payload = array_merge($request->validated(), ['status' => 'promise_to_pay']);
return response()->json(['ok' => true, 'note' => $this->parentPaymentFollowUpService->storeNote($parent, $payload, optional($request->user())->id)], 201);
}
public function resolveParentFollowUp(FollowUpNoteRequest $request, int $parent): JsonResponse
{
$payload = array_merge($request->validated(), ['status' => 'resolved']);
return response()->json(['ok' => true, 'note' => $this->parentPaymentFollowUpService->storeNote($parent, $payload, optional($request->user())->id)], 201);
}
@@ -168,7 +168,7 @@ class FinancialController extends BaseApiController
fputcsv($out, $row);
}
fclose($out);
}, 'stakeholder_financial_analysis_' . $schoolYear . '_' . date('Ymd_His') . '.csv', ['Content-Type' => 'text/csv']);
}, 'stakeholder_financial_analysis_'.$schoolYear.'_'.date('Ymd_His').'.csv', ['Content-Type' => 'text/csv']);
}
public function downloadCsv(FinancialReportRequest $request): StreamedResponse
@@ -200,7 +200,7 @@ class FinancialController extends BaseApiController
$breakdown = $report['paymentBreakdown'] ?? [];
$filename = 'financial_report_' . date('Ymd_His') . '.csv';
$filename = 'financial_report_'.date('Ymd_His').'.csv';
return response()->streamDownload(function () use ($report, $paymentsMap, $refundsMap, $discountsMap, $breakdown) {
$out = fopen('php://output', 'w');
@@ -309,6 +309,6 @@ class FinancialController extends BaseApiController
return response()->streamDownload(function () use ($pdfBytes) {
echo $pdfBytes;
}, 'Financial_Report_' . $schoolYear . '.pdf', ['Content-Type' => 'application/pdf']);
}, 'Financial_Report_'.$schoolYear.'.pdf', ['Content-Type' => 'application/pdf']);
}
}
@@ -13,17 +13,52 @@ class InstallmentPlanController extends Controller
{
public function __construct(private InstallmentPlanService $service) {}
public function index(Request $request): JsonResponse { return response()->json(['ok' => true, 'plans' => $this->service->list($request->query())]); }
public function store(InstallmentPlanRequest $request, int $invoice): JsonResponse { return response()->json(['ok' => true, 'plan' => $this->service->createForInvoice($invoice, $request->validated(), optional($request->user())->id)], 201); }
public function show(int $plan): JsonResponse { return response()->json(['ok' => true, 'plan' => $this->service->show($plan)]); }
public function activate(Request $request, int $plan): JsonResponse { return response()->json(['ok' => true, 'plan' => $this->service->activate($plan, optional($request->user())->id)]); }
public function cancel(int $plan): JsonResponse { return response()->json(['ok' => true, 'plan' => $this->service->cancel($plan)]); }
public function index(Request $request): JsonResponse
{
return response()->json(['ok' => true, 'plans' => $this->service->list($request->query())]);
}
public function store(InstallmentPlanRequest $request, int $invoice): JsonResponse
{
return response()->json(['ok' => true, 'plan' => $this->service->createForInvoice($invoice, $request->validated(), optional($request->user())->id)], 201);
}
public function show(int $plan): JsonResponse
{
return response()->json(['ok' => true, 'plan' => $this->service->show($plan)]);
}
public function activate(Request $request, int $plan): JsonResponse
{
return response()->json(['ok' => true, 'plan' => $this->service->activate($plan, optional($request->user())->id)]);
}
public function cancel(int $plan): JsonResponse
{
return response()->json(['ok' => true, 'plan' => $this->service->cancel($plan)]);
}
public function restructure(InstallmentPlanRequest $request, int $plan): JsonResponse
{
$old = $this->service->cancel($plan);
return response()->json(['ok' => true, 'old_plan' => $old, 'message' => 'Old plan cancelled. Create a replacement plan against the invoice to preserve audit history.']);
}
public function allocatePayment(PaymentAllocationRequest $request, int $payment): JsonResponse { return response()->json(['ok' => true, 'result' => $this->service->allocatePayment($payment, $request->validated())]); }
public function due(): JsonResponse { return response()->json(['ok' => true, 'installments' => $this->service->due(false)]); }
public function overdue(): JsonResponse { $this->service->markOverdue(); return response()->json(['ok' => true, 'installments' => $this->service->due(true)]); }
public function allocatePayment(PaymentAllocationRequest $request, int $payment): JsonResponse
{
return response()->json(['ok' => true, 'result' => $this->service->allocatePayment($payment, $request->validated())]);
}
public function due(): JsonResponse
{
return response()->json(['ok' => true, 'installments' => $this->service->due(false)]);
}
public function overdue(): JsonResponse
{
$this->service->markOverdue();
return response()->json(['ok' => true, 'installments' => $this->service->due(true)]);
}
}
@@ -111,7 +111,7 @@ class InvoiceController extends BaseApiController
$status = $request->validated()['status'];
$updated = Invoice::updateInvoiceStatus($invoiceId, $status);
if (!$updated) {
if (! $updated) {
return response()->json(['ok' => false, 'message' => 'Invoice not found.'], 404);
}
@@ -151,12 +151,9 @@ class InvoiceController extends BaseApiController
return response()->streamDownload(function () use ($pdfBytes) {
echo $pdfBytes;
}, 'invoice_' . $invoiceId . '.pdf', ['Content-Type' => 'application/pdf']);
}, 'invoice_'.$invoiceId.'.pdf', ['Content-Type' => 'application/pdf']);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -82,7 +82,7 @@ class PaymentController extends BaseApiController
$payload = $validator->validated();
$updated = $this->balanceService->updateBalance($paymentId, (float) $payload['paid_amount']);
if (!$updated) {
if (! $updated) {
return response()->json(['ok' => false, 'message' => 'Payment not found.'], 404);
}
@@ -69,9 +69,6 @@ class PaymentEventChargesController extends BaseApiController
return response()->json(['ok' => true, 'students' => $students]);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -110,12 +110,10 @@ class PaymentManualController extends BaseApiController
public function file(Request $request, string $filename)
{
$mode = (string) ($request->query('mode') ?? 'download');
return $this->service->serveCheckFile($filename, $mode);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -83,7 +83,7 @@ class PaymentTransactionController extends BaseApiController
$updated = $this->service->updateStatus($transactionId, (string) $status);
if (!$updated) {
if (! $updated) {
return response()->json(['ok' => false, 'message' => 'Transaction not found.'], 404);
}
@@ -39,7 +39,7 @@ class PaypalTransactionsController extends BaseApiController
$payload = $request->validated();
$rows = $this->service->listAll($payload['q'] ?? null);
$filename = 'paypal_transactions_' . date('Ymd_His') . '.csv';
$filename = 'paypal_transactions_'.date('Ymd_His').'.csv';
return response()->streamDownload(function () use ($rows) {
$out = fopen('php://output', 'w');
@@ -52,7 +52,7 @@ class PurchaseOrderController extends BaseApiController
public function show(int $id): JsonResponse
{
$data = $this->queryService->find($id);
if (!$data) {
if (! $data) {
return response()->json(['ok' => false, 'message' => 'Purchase order not found.'], 404);
}
@@ -69,7 +69,7 @@ class PurchaseOrderController extends BaseApiController
$validator = Validator::make($data, [
'po_number' => ['required', 'string', 'max:60'],
'supplier_id' => ['required', 'integer', 'min:1', 'exists:suppliers,id'],
'status' => ['nullable', 'string', 'in:' . implode(',', PurchaseOrder::allowedStatuses())],
'status' => ['nullable', 'string', 'in:'.implode(',', PurchaseOrder::allowedStatuses())],
'order_date' => ['nullable', 'date'],
'expected_date' => ['nullable', 'date'],
'notes' => ['nullable', 'string', 'max:5000'],
@@ -88,7 +88,7 @@ class PurchaseOrderController extends BaseApiController
}
$payload = $validator->validated();
if (!empty($payload['order_date']) && !empty($payload['expected_date'])) {
if (! empty($payload['order_date']) && ! empty($payload['expected_date'])) {
$orderTs = strtotime((string) $payload['order_date']);
$expectedTs = strtotime((string) $payload['expected_date']);
if ($orderTs !== false && $expectedTs !== false && $expectedTs < $orderTs) {
@@ -136,7 +136,7 @@ class PurchaseOrderController extends BaseApiController
$payload = $validator->validated();
$po = PurchaseOrder::query()->find($id);
if (!$po) {
if (! $po) {
return response()->json(['ok' => false, 'message' => 'Purchase order not found.'], 404);
}
@@ -169,7 +169,7 @@ class PurchaseOrderController extends BaseApiController
}
$po = PurchaseOrder::query()->find($id);
if (!$po) {
if (! $po) {
return response()->json(['ok' => false, 'message' => 'Purchase order not found.'], 404);
}
@@ -48,7 +48,7 @@ class RefundController extends BaseApiController
public function show(int $refundId): JsonResponse
{
$refund = $this->queryService->find($refundId);
if (!$refund) {
if (! $refund) {
return response()->json(['ok' => false, 'message' => 'Refund not found.'], 404);
}
@@ -71,6 +71,7 @@ class RefundController extends BaseApiController
$result = $this->requestService->requestRefund($payload, $guard);
} catch (\Throwable $e) {
Log::error('Refund request failed.', ['error' => $e->getMessage()]);
return response()->json(['ok' => false, 'message' => 'Failed to submit refund request.'], 500);
}
@@ -212,9 +213,6 @@ class RefundController extends BaseApiController
]);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -93,6 +93,7 @@ class ReimbursementController extends BaseApiController
} catch (RuntimeException $e) {
$message = $e->getMessage();
$status = str_contains($message, 'not found') ? 404 : (str_contains($message, 'already') ? 409 : 422);
return response()->json(['ok' => false, 'message' => $message], $status);
} catch (\Throwable $e) {
return response()->json(['ok' => false, 'message' => 'Unable to mark donation right now.'], 500);
@@ -144,7 +145,7 @@ class ReimbursementController extends BaseApiController
$adminIdRaw = $payload['admin_id'] ?? null;
$adminId = ($adminIdRaw === '' || $adminIdRaw === null) ? null : (int) $adminIdRaw;
$reimbursementId = !empty($payload['reimbursement_id']) ? (int) $payload['reimbursement_id'] : null;
$reimbursementId = ! empty($payload['reimbursement_id']) ? (int) $payload['reimbursement_id'] : null;
try {
$result = $this->assignmentService->updateAssignment(
@@ -184,6 +185,7 @@ class ReimbursementController extends BaseApiController
} catch (RuntimeException $e) {
$message = $e->getMessage();
$status = str_contains($message, 'check file') ? 409 : 404;
return response()->json(['ok' => false, 'message' => $message], $status);
} catch (\Throwable $e) {
return response()->json(['ok' => false, 'message' => 'Unable to lock batch right now.'], 500);
@@ -204,7 +206,7 @@ class ReimbursementController extends BaseApiController
$adminId = (int) $payload['admin_id'];
$batch = ReimbursementBatch::query()->find($batchId);
if (!$batch) {
if (! $batch) {
return response()->json(['ok' => false, 'message' => 'Batch not found.'], 404);
}
if (strtolower((string) ($batch->status ?? '')) !== ReimbursementBatch::STATUS_OPEN) {
@@ -231,7 +233,7 @@ class ReimbursementController extends BaseApiController
return response(file_get_contents($meta['path']), 200, [
'Content-Type' => $meta['mime'],
'Content-Disposition' => $disposition . '; filename="' . $meta['download_name'] . '"',
'Content-Disposition' => $disposition.'; filename="'.$meta['download_name'].'"',
'Content-Length' => (string) $meta['size'],
'ETag' => $meta['etag'],
'Last-Modified' => $meta['last_modified'],
@@ -281,7 +283,7 @@ class ReimbursementController extends BaseApiController
return response()->json(['ok' => false, 'message' => $e->getMessage()], 404);
}
if (!$ok) {
if (! $ok) {
return response()->json(['ok' => false, 'message' => 'Failed to send email. Please try again.'], 500);
}
@@ -301,7 +303,7 @@ class ReimbursementController extends BaseApiController
return response()->streamDownload(function () use ($csv) {
$out = fopen('php://output', 'w');
fprintf($out, chr(0xEF) . chr(0xBB) . chr(0xBF));
fprintf($out, chr(0xEF).chr(0xBB).chr(0xBF));
foreach ($csv['rows'] as $row) {
fputcsv($out, $row);
}
@@ -318,7 +320,7 @@ class ReimbursementController extends BaseApiController
return response()->streamDownload(function () use ($csv) {
$out = fopen('php://output', 'w');
fprintf($out, chr(0xEF) . chr(0xBB) . chr(0xBF));
fprintf($out, chr(0xEF).chr(0xBB).chr(0xBF));
foreach ($csv['rows'] as $row) {
fputcsv($out, $row);
}
@@ -436,7 +438,7 @@ class ReimbursementController extends BaseApiController
}
$reimb = Reimbursement::query()->find($id);
if (!$reimb) {
if (! $reimb) {
return response()->json(['ok' => false, 'message' => 'Reimbursement not found.'], 404);
}
@@ -464,7 +466,7 @@ class ReimbursementController extends BaseApiController
if ($request->hasFile('receipt')) {
$receiptName = $this->fileService->storeReceipt($request->file('receipt'));
}
if (!empty($payload['remove_receipt'])) {
if (! empty($payload['remove_receipt'])) {
$receiptName = null;
}
@@ -478,9 +480,6 @@ class ReimbursementController extends BaseApiController
]);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);