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

conedevelopment / bazar / 20694116184

04 Jan 2026 02:08PM UTC coverage: 68.615% (+4.5%) from 64.117%
20694116184

push

github

iamgergo
version

1679 of 2447 relevant lines covered (68.61%)

25.06 hits per line

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

15.0
/src/Fields/OrderStatus.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Cone\Bazar\Fields;
6

7
use Closure;
8
use Cone\Bazar\Models\Order;
9
use Cone\Root\Fields\Select;
10
use Illuminate\Database\Eloquent\Model;
11
use Illuminate\Http\Request;
12

13
class OrderStatus extends Select
14
{
15
    /**
16
     * Create a new field instance.
17
     */
18
    public function __construct(?string $label = null, Closure|string $modelAttribute = 'status')
101✔
19
    {
20
        parent::__construct($label ?: __('Status'), $modelAttribute);
101✔
21

22
        $this->options(Order::getStatuses());
101✔
23
    }
24

25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function resolveFormat(Request $request, Model $model): ?string
×
29
    {
30
        $value = parent::resolveFormat($request, $model);
×
31

32
        if (is_null($value)) {
×
33
            return $value;
×
34
        }
35

36
        return sprintf(
×
37
            '<span class="status %s">%s</span>',
×
38
            $this->valueToClass($this->resolveValue($request, $model)),
×
39
            $value,
×
40
        );
×
41
    }
42

43
    /**
44
     * Convert the value to a class name.
45
     */
46
    public function valueToClass(string $value): string
×
47
    {
48
        return match ($value) {
×
49
            Order::PENDING, Order::ON_HOLD => 'status--warning',
×
50
            Order::CANCELLED, Order::FAILED => 'status--danger',
×
51
            Order::FULFILLED => 'status--success',
×
52
            Order::IN_PROGRESS => 'status--info',
×
53
            default => 'status--info',
×
54
        };
×
55
    }
56
}
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