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

conedevelopment / bazar / 20248285521

15 Dec 2025 09:37PM UTC coverage: 61.163% (-2.3%) from 63.48%
20248285521

Pull #235

github

web-flow
Merge c10e94de1 into 090ff8496
Pull Request #235: Coupons & Discounts

58 of 144 new or added lines in 18 files covered. (40.28%)

14 existing lines in 3 files now uncovered.

989 of 1617 relevant lines covered (61.16%)

14.83 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();
64✔
27

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

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

32
        $this->as(Number::class, function (Number $field): void {
64✔
33
            $field->min(0)
64✔
34
                ->format(static function (Request $request, Model $model, mixed $value): ?string {
64✔
35
                    return match (true) {
NEW
36
                        is_null($value) => null,
×
NEW
37
                        default => $model->checkoutable->getCurrency()->format((float) ($value ?? 0)),
×
38
                    };
39
                })
64✔
40
                ->suffix($this->currency->value);
64✔
41
        });
64✔
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