3 kupon türü, dosya etki haritası, simülasyon örnekleri ve akış diyagramları
Kupon sistemi, kullanıcılara ödeme sırasında veya profil sayfasından indirim/avantaj sağlayan bir yapıdır. Admin panelinden kupon oluşturulur, kullanıcılara dağıtılır ve belirli koşullar altında geçerli olur.
Toplam tutarın belirli bir yüzdesi kadar indirim yapılır. Örneğin %20 indirim kuponu, 100 TL’lik alışverişte 20 TL düşer.
Sabit bir miktar düşülür. Örneğin 50 TL indirim kuponu, fiyat ne olursa olsun 50 TL düşer (sıfırın altına inmez).
Abonelik süresine ek gün eklenir. Örneğin 30 günlük kupon, mevcut aboneliği 30 gün uzatır. Ödeme sayfasından değil, profil sayfasından kullanılır.
| Tür | DB Değer | Uygulama Noktası | Hesaplama | Koşul |
|---|---|---|---|---|
| Yüzde | percentage |
Checkout sayfası | tutar * (discount_value / 100) |
max_discount_amount kontrolü |
| Sabit Tutar | fixed_amount |
Checkout sayfası | tutar - discount_value |
Sıfırın altına inmez |
| Bedava Gün | free_days |
Profil sayfası | ends_at + free_days gün |
Aktif abonelik gerekli |
coupons.discount_type = 'percentage'
price * (discount_value / 100)
max_discount_amount
ile üst limit
Coupon::apply($price)
coupons.discount_type = 'fixed_amount'
max(0, price - discount_value)
max(0, ...))
Coupon::apply($price)
coupons.discount_type = 'free_days'
coupons.free_days (integer, nullable)
subscription.ends_at->addDays(free_days)
CouponService::applyFreeDays()
SubscriptionService::extendByDays()
Kupon sistemi toplam 20+ dosyayı etkiler. Veritabanı değişikliği (migration), model, servis, admin formu, admin görünümü, checkout sayfası, profil sayfası, raporlama, routing ve dil dosyaları dahildir. Aşağıdaki tabloda her dosya, hangi modülde olduğu ve ne değiştiği yer alır.
| # | Dosya | Modül | Değişiklik |
|---|---|---|---|
| 1 |
2026_02_28_000001_update_coupons_types_and_add_free_days.php
Modules/Coupon/database/migrations/ (central + tenant)
|
Migration | discount_type enum güncellemesi (3 tür); free_days kolonu ekleme; eski türlerin kaldırılması |
| 2 |
Coupon.php
Modules/Coupon/App/Models/
|
Model | free_days fillable; apply() metodu; isFreeDaysCoupon(); getDiscountDisplay() |
| 3 |
CouponManageComponent.php
Modules/Coupon/App/Http/Livewire/
|
Admin | free_days property; validasyon kuralları; save() güncellemesi; discount_type seçenekleri 3’e indirildi |
| 4 |
coupon-manage-component.blade.php
Modules/Coupon/resources/views/livewire/
|
Blade | 3 adet radio buton (percentage, fixed_amount, free_days); free_days input alanı; koşullu görünürlük |
| 5 |
CouponService.php
Modules/Coupon/App/Services/
|
Service | applyFreeDays() metodu; abonelik uzatma lojigi; kupon kullanım kaydı |
| 6 |
SubscriptionService.php
Modules/Subscription/App/Services/
|
Service | extendByDays($subscription, $days) metodu; ends_at tarih uzatma |
| 7 |
CheckoutPage.php
Modules/Subscription/App/Http/Livewire/
|
Checkout | couponCode, appliedCoupon, couponDiscount property’leri; applyCoupon() / removeCoupon() |
| 8 |
checkout-page.blade.php
Modules/Subscription/resources/views/livewire/
|
Blade | Kupon kodu input alanı; “Uygula” / “Kaldır” butonları; indirim satırı gösterimi |
| 9 |
RedeemCouponComponent.php
Modules/Coupon/App/Http/Livewire/
|
Profil | Profil sayfasından free_days kuponu uygulama; kupon doğrulama; abonelik kontrolü |
| 10 |
redeem-coupon-component.blade.php
Modules/Coupon/resources/views/livewire/
|
Blade | Frontend kupon giriş UI; başarı/hata mesajları; abonelik uzatma bildirimi |
| 11 |
CouponReportComponent.php
Modules/Coupon/App/Http/Livewire/
|
Rapor | Genel kupon rapor sayfası; kullanım istatistikleri; tür bazlı gruplama |
| 12 |
coupon-report-component.blade.php
Modules/Coupon/resources/views/livewire/
|
Blade | Rapor tablo görünümü; filtreler; kupon türüne göre ikonlar |
| 13 |
CouponReportDetailComponent.php
Modules/Coupon/App/Http/Livewire/
|
Rapor | Tekil kupon detay raporu; kullanıcı listesi; kullanım geçmişi |
| 14 |
coupon-report-detail-component.blade.php
Modules/Coupon/resources/views/livewire/
|
Blade | Detay rapor görünümü; kullanıcı tablosu; tarih filtreleri |
| 15 |
admin.php
Modules/Coupon/routes/
|
Route | reports ve reports.detail route’ları eklendi |
| 16 |
helper.blade.php
Modules/Coupon/resources/views/
|
Menü | Admin menüsüne “Kupon Raporları” linki eklendi |
| 17 |
CouponServiceProvider.php
Modules/Coupon/App/Providers/
|
Provider | Yeni Livewire component kayıtları (RedeemCoupon, CouponReport, CouponReportDetail) |
| 18 |
tr/admin.php
Modules/Coupon/resources/lang/
|
Lang | Türkçe çeviriler: “Bedava Gün”, “Gün Sayısı”, rapor başlıkları |
| 19 |
en/admin.php
Modules/Coupon/resources/lang/
|
Lang | İngilizce çeviriler: “Free Days”, “Day Count”, report headings |
| 20 |
profile/edit.blade.php
resources/views/themes/
|
Profil | Profil düzenleme sayfasına @livewire('redeem-coupon') bileşeni eklendi |
Aşağıdaki örnekler, her kupon türünün farklı senaryolarda nasıl çalıştığını gösterir. Gerçek kullanımda da tam olarak bu hesaplamalar yapılır.
max_discount_amount = 100 devrede → 240 TL yerine 100 TL indirim
max(0, ...) sayesinde negatif ödeme olmaz
ends_at alanı 7 gün ileri taşınır
CheckoutPage::$couponCode ← wire:modelwire:click="applyCoupon"Coupon::where('code', $code)->first() → status, date, limit kontrolüif ($coupon->isFreeDaysCoupon()) → error (checkout'ta kullanılamaz)$coupon->apply($price) → $couponDiscount$appliedCoupon, $couponDiscount Livewire ile rendercoupon_usages tablosuna kayıt; used_count++Bedava gün kuponu, ödeme sayfasından farklı çalışır. Kullanıcı profil sayfasındaki “Kupon Kullan” alanına kodunu girer. Para ödemesi yoktur; mevcut abonelik süresi belirtilen gün kadar uzatılır.
@livewire('redeem-coupon') — profile/edit.blade.phpRedeemCouponComponent::$couponCode ← wire:modelCoupon::where('code', $code)->isFreeDaysCoupon() kontrolü$user->activeSubscription() → yoksa hata mesajı$subscription->ends_at->addDays($coupon->free_days)| Özellik | Checkout (Yüzde / Sabit) | Profil (Bedava Gün) |
|---|---|---|
| Uygulama Yeri | Ödeme sayfası | Profil sayfası |
| Para İndirimi | Evet — fiyattan düşülür | Hayır — para işlemi yok |
| Süre Uzatma | Hayır | Evet — ends_at uzatılır |
| Abonelik Gerekli mi? | Hayır (yeni alım için) | Evet — aktif abonelik şart |
| Livewire Component | CheckoutPage |
RedeemCouponComponent |
| Kullanım Amacı | Kampanya, promosyon, indirim | Sadakat ödülü, telafi, hediye |