From de5bd1621985ac9f135c34629feef9d95e7ba1b3 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Wed, 10 Jun 2026 09:42:06 +0000 Subject: [PATCH] Fix systemic extraction breakage in authenticated UI. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The give→merchant transform left several independent breakages that 500'd once a logged-in user hit the pages: - /storefronts/{create,show,update,...} were wired to Qr\QrCodeController, which renders events-lineage qr-codes.* views referencing 14 undefined events.* routes. Rewire to StorefrontController (clean storefronts.* views). - storefronts/show.blade.php @include('give.storefronts.partials.*') — the view dir was renamed give→merchant but the include namespace wasn't. - /payouts + /search queried qr_sale_orders.*_minor; migration created *_ghs. - Remove dead GiveDonation model (nonexistent give_donations table). Co-Authored-By: Claude Opus 4.8 --- .../Merchant/PayoutsController.php | 4 +- app/Http/Controllers/SearchController.php | 2 +- app/Models/GiveDonation.php | 59 ------------------- .../views/merchant/storefronts/show.blade.php | 6 +- routes/web.php | 11 ++-- 5 files changed, 11 insertions(+), 71 deletions(-) delete mode 100644 app/Models/GiveDonation.php diff --git a/app/Http/Controllers/Merchant/PayoutsController.php b/app/Http/Controllers/Merchant/PayoutsController.php index 0c2aaca..be1c1ae 100644 --- a/app/Http/Controllers/Merchant/PayoutsController.php +++ b/app/Http/Controllers/Merchant/PayoutsController.php @@ -22,10 +22,10 @@ class PayoutsController extends Controller ->where('type', QrCode::TYPE_SHOP) ->pluck('id'); - $revenueMinor = (int) QrSaleOrder::query() + $revenueMinor = (int) round(QrSaleOrder::query() ->whereIn('qr_code_id', $qrIds) ->where('status', QrSaleOrder::STATUS_PAID) - ->sum('merchant_amount_minor'); + ->sum('merchant_amount_ghs') * 100); $balanceMinor = 0; try { diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index f51ab78..10874c4 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -55,7 +55,7 @@ class SearchController extends Controller ->get() ->map(function (QrSaleOrder $order): array { $amount = number_format( - ($order->status === QrSaleOrder::STATUS_PAID ? $order->merchant_amount_minor : $order->amount_minor) / 100, + (float) ($order->status === QrSaleOrder::STATUS_PAID ? $order->merchant_amount_ghs : $order->amount_ghs), 2, ); diff --git a/app/Models/GiveDonation.php b/app/Models/GiveDonation.php deleted file mode 100644 index 7e80697..0000000 --- a/app/Models/GiveDonation.php +++ /dev/null @@ -1,59 +0,0 @@ - 'integer', - 'platform_fee_minor' => 'integer', - 'merchant_amount_minor' => 'integer', - 'metadata' => 'array', - 'paid_at' => 'datetime', - ]; - - public function qrCode(): BelongsTo - { - return $this->belongsTo(QrCode::class); - } - - public function merchant(): BelongsTo - { - return $this->belongsTo(User::class, 'user_id'); - } - - public function amountMajor(): float - { - return $this->amount_minor / 100; - } -} diff --git a/resources/views/merchant/storefronts/show.blade.php b/resources/views/merchant/storefronts/show.blade.php index 2b37ba8..6f05f1d 100644 --- a/resources/views/merchant/storefronts/show.blade.php +++ b/resources/views/merchant/storefronts/show.blade.php @@ -8,7 +8,7 @@

{{ $qrCode->label }}

{{ $c['name'] ?? '' }}@if(!empty($c['denomination'])) · {{ $c['denomination'] }}@endif

- @include('give.storefronts.partials.header-actions', ['qrCode' => $qrCode]) + @include('merchant.storefronts.partials.header-actions', ['qrCode' => $qrCode]) @if(session('success')) @@ -17,7 +17,7 @@
- @include('give.storefronts.partials.preview-card', [ + @include('merchant.storefronts.partials.preview-card', [ 'qrCode' => $qrCode, 'previewDataUri' => $previewDataUri, 'showDownloads' => false, @@ -75,7 +75,7 @@ Delete storefront
- @include('give.storefronts.partials.delete-modal', ['qrCode' => $qrCode]) + @include('merchant.storefronts.partials.delete-modal', ['qrCode' => $qrCode])
diff --git a/routes/web.php b/routes/web.php index 65ce0e7..34a07d8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,7 +11,6 @@ use App\Http\Controllers\Public\QrScanController; use App\Http\Controllers\Public\SaleOrderController; use App\Http\Controllers\Qr\AccountController; use App\Http\Controllers\Qr\AfiaController; -use App\Http\Controllers\Qr\QrCodeController; use App\Http\Controllers\Qr\TeamController; use App\Http\Controllers\SearchController; use Illuminate\Support\Facades\Route; @@ -53,11 +52,11 @@ Route::middleware(['auth'])->group(function () { Route::post('/afia/chat', [AfiaController::class, 'chat'])->name('merchant.afia.chat'); Route::get('/storefronts', [StorefrontController::class, 'index'])->name('merchant.storefronts.index'); - Route::get('/storefronts/create', [QrCodeController::class, 'create'])->name('merchant.storefronts.create'); - Route::post('/storefronts', [QrCodeController::class, 'store'])->name('merchant.storefronts.store'); - Route::get('/storefronts/{storefront}', [QrCodeController::class, 'show'])->name('merchant.storefronts.show'); - Route::patch('/storefronts/{storefront}', [QrCodeController::class, 'update'])->name('merchant.storefronts.update'); - Route::delete('/storefronts/{storefront}', [QrCodeController::class, 'destroy'])->name('merchant.storefronts.destroy'); + Route::get('/storefronts/create', [StorefrontController::class, 'create'])->name('merchant.storefronts.create'); + Route::post('/storefronts', [StorefrontController::class, 'store'])->name('merchant.storefronts.store'); + Route::get('/storefronts/{storefront}', [StorefrontController::class, 'show'])->name('merchant.storefronts.show'); + Route::patch('/storefronts/{storefront}', [StorefrontController::class, 'update'])->name('merchant.storefronts.update'); + Route::delete('/storefronts/{storefront}', [StorefrontController::class, 'destroy'])->name('merchant.storefronts.destroy'); Route::get('/storefronts/{storefront}/preview.png', [StorefrontController::class, 'preview'])->name('merchant.storefronts.preview'); Route::get('/storefronts/{storefront}/download/{format}', [StorefrontController::class, 'download'])->name('merchant.storefronts.download')->whereIn('format', ['png', 'svg', 'pdf']);