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

conedevelopment / bazar / 20312400741

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

Pull #235

github

web-flow
Merge 705e249c7 into 090ff8496
Pull Request #235: 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

64.29
/src/Fields/Price.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Cone\Bazar\Fields;
6

7
use Cone\Bazar\Bazar;
8
use Cone\Bazar\Enums\Currency;
9
use Cone\Root\Fields\Meta;
10
use Cone\Root\Fields\Number;
11
use Illuminate\Database\Eloquent\Model;
12
use Illuminate\Http\Request;
13

14
class Price extends Meta
15
{
16
    /**
17
     * The price currency.
18
     */
19
    protected Currency $currency;
20

21
    /**
22
     * Create a new price field instance.
23
     */
24
    public function __construct(string $label, ?Currency $currency = null)
25
    {
26
        $this->currency = $currency ?: Bazar::getCurrency();
70✔
27

28
        parent::__construct($label, sprintf('price_%s', $this->currency->key()));
70✔
29

30
        $this->aggregateResolver = null;
70✔
31

32
        $this->as(Number::class, function (Number $field): void {
70✔
33
            $field->min(0)
70✔
34
                ->format(function (Request $request, Model $model, mixed $value): ?string {
70✔
35
                    return match (true) {
NEW
36
                        is_null($value) => null,
×
NEW
37
                        default => $this->currency->format((float) ($value ?? 0)),
×
38
                    };
39
                })
70✔
40
                ->suffix($this->currency->value);
70✔
41
        });
70✔
42
    }
43

44
    /**
45
     * Set the currency attribute.
46
     */
47
    public function currency(Currency $value): static
48
    {
49
        $this->currency = $value;
×
50

NEW
51
        $this->modelAttribute = sprintf('price_%s', $value->key());
×
52

53
        return $this;
×
54
    }
55
}
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