Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
FeatureResource
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 toArray
100.00% covered (success)
100.00%
13 / 13
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Http\Resources\v2;
4
5use Illuminate\Http\Request;
6use Illuminate\Http\Resources\Json\JsonResource;
7
8/**
9 * Resource for transforming Feature models for API responses.
10 *
11 * @property string $_id The feature ID
12 * @property string $key The feature key
13 * @property string $name The feature name
14 * @property string|null $description The feature description
15 * @property string $value_type The type of value (boolean, integer, string, array, object)
16 * @property string $category The feature category
17 * @property mixed $default_value The default value
18 * @property bool $is_active Whether the feature is active
19 * @property int $display_order The display order
20 * @property \Carbon\Carbon|null $created_at When the feature was created
21 * @property \Carbon\Carbon|null $updated_at When the feature was last updated
22 */
23class FeatureResource extends JsonResource
24{
25    /**
26     * Transform the resource into an array.
27     *
28     * @return array<string, mixed>
29     */
30    public function toArray(Request $request): array
31    {
32        return [
33            'id' => (string) $this->_id,
34            'key' => $this->key,
35            'name' => $this->name,
36            'description' => $this->description,
37            'value_type' => $this->value_type,
38            'category' => $this->category,
39            'default_value' => $this->default_value,
40            'is_active' => (bool) $this->is_active,
41            'display_order' => (int) $this->display_order,
42            'created_at' => $this->created_at?->timestamp,
43            'updated_at' => $this->updated_at?->timestamp,
44        ];
45    }
46}