• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

conedevelopment / bazar / 20312410163

17 Dec 2025 05:58PM UTC coverage: 64.395% (+0.9%) from 63.48%
20312410163

push

github

web-flow
Merge pull request #235 from conedevelopment/coupons

Coupons & Discounts

204 of 260 new or added lines in 23 files covered. (78.46%)

8 existing lines in 1 file now uncovered.

1096 of 1702 relevant lines covered (64.39%)

18.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.0
/src/Models/AppliedCoupon.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Cone\Bazar\Models;
6

7
use Cone\Bazar\Interfaces\Models\AppliedCoupon as Contract;
8
use Cone\Root\Traits\InteractsWithProxy;
9
use Illuminate\Database\Eloquent\Casts\Attribute;
10
use Illuminate\Database\Eloquent\Relations\BelongsTo;
11
use Illuminate\Database\Eloquent\Relations\MorphPivot;
12
use Illuminate\Database\Eloquent\Relations\MorphTo;
13

14
class AppliedCoupon extends MorphPivot implements Contract
15
{
16
    use InteractsWithProxy;
17

18
    /**
19
     * The attributes that should have default values.
20
     *
21
     * @var array<string, mixed>
22
     */
23
    protected $attributes = [
24
        'value' => 0,
25
    ];
26

27
    /**
28
     * The attributes that are mass assignable.
29
     *
30
     * @var list<string>
31
     */
32
    protected $fillable = [
33
        'value',
34
    ];
35

36
    /**
37
     * The table associated with the model.
38
     *
39
     * @var string
40
     */
41
    protected $table = 'bazar_couponables';
42

43
    /**
44
     * Get the proxied interface.
45
     */
46
    public static function getProxiedInterface(): string
47
    {
48
        return Contract::class;
1✔
49
    }
50

51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function casts(): array
55
    {
56
        return [
38✔
57
            'value' => 'float',
38✔
58
        ];
38✔
59
    }
60

61
    /**
62
     * Get the coupon for the model.
63
     */
64
    public function coupon(): BelongsTo
65
    {
NEW
66
        return $this->belongsTo(Coupon::getProxiedClass());
×
67
    }
68

69
    /**
70
     * Get the couponable model for the model.
71
     */
72
    public function couponable(): MorphTo
73
    {
NEW
74
        return $this->morphTo();
×
75
    }
76

77
    /**
78
     * Get the formatted value attribute.
79
     */
80
    protected function formattedValue(): Attribute
81
    {
82
        return new Attribute(
1✔
83
            get: fn (): string => $this->format()
1✔
84
        );
1✔
85
    }
86

87
    /**
88
     * Get the formatted coupon value.
89
     */
90
    public function format(): string
91
    {
NEW
92
        return $this->pivotParent?->checkoutable?->getCurrency()?->format($this->value) ?: '';
×
93
    }
94
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc