PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.14.2
Yatra – Travel Booking & Tour Operator Software v3.0.14.2
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / app / Models / TravelerCategory.php

TravelerCategory.php in Yatra – Travel Booking & Tour Operator Software 3.0.14.2, at app/Models/TravelerCategory.php

152 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Models;
6
7 /**
8 * Traveler Category Model
9 * Represents a traveler category entity
10 */
11 class TravelerCategory
12 {
13 /**
14 * @var int
15 */
16 public int $id;
17
18 /**
19 * @var string
20 */
21 public string $label;
22
23 /**
24 * @var string
25 */
26 public string $slug;
27
28 /**
29 * @var string
30 */
31 public string $description;
32
33 /**
34 * @var int|null
35 */
36 public ?int $age_min;
37
38 /**
39 * @var int|null
40 */
41 public ?int $age_max;
42
43 /**
44 * @var string Pricing mode (per_person or per_group)
45 */
46 public string $pricing_mode;
47
48 /**
49 * @var int|null Minimum group size when pricing per group
50 */
51 public ?int $min_pax;
52
53 /**
54 * @var int|null Maximum group size when pricing per group
55 */
56 public ?int $max_pax;
57
58 /**
59 * @var string How a party larger than max_pax is handled when pricing per
60 * group: 'block' (cap at max, default) or 'per_block' (charge
61 * one flat price per block of max_pax people).
62 */
63 public string $group_overflow = 'block';
64
65 /**
66 * @var array|null Icon data (type and value)
67 */
68 public ?array $icon;
69
70 /**
71 * @var string
72 */
73 public string $status;
74
75 /**
76 * @var string
77 */
78 public string $created_at;
79
80 /**
81 * @var string
82 */
83 public string $updated_at;
84
85 /**
86 * @var int
87 */
88 public int $created_by;
89
90 /**
91 * @var int
92 */
93 public int $updated_by;
94
95 /**
96 * Create from array
97 */
98 public static function fromArray(array $data): self
99 {
100 $category = new self();
101
102 $category->id = (int) ($data['id'] ?? 0);
103 $category->label = $data['label'] ?? '';
104 $category->slug = $data['slug'] ?? '';
105 $category->description = $data['description'] ?? '';
106 $category->age_min = isset($data['age_min']) && $data['age_min'] !== '' ? (int) $data['age_min'] : null;
107 $category->age_max = isset($data['age_max']) && $data['age_max'] !== '' ? (int) $data['age_max'] : null;
108 $category->pricing_mode = isset($data['pricing_mode']) && in_array($data['pricing_mode'], ['per_person', 'per_group'], true)
109 ? $data['pricing_mode']
110 : 'per_person';
111 $category->min_pax = isset($data['min_pax']) && $data['min_pax'] !== '' ? (int) $data['min_pax'] : null;
112 $category->max_pax = isset($data['max_pax']) && $data['max_pax'] !== '' ? (int) $data['max_pax'] : null;
113 $category->group_overflow = isset($data['group_overflow']) && in_array($data['group_overflow'], ['block', 'per_block'], true)
114 ? $data['group_overflow']
115 : 'block';
116 $category->icon = isset($data['icon']) ? (is_array($data['icon']) ? $data['icon'] : maybe_unserialize($data['icon'])) : null;
117 $category->status = $data['status'] ?? 'draft';
118 $category->created_at = $data['created_at'] ?? '';
119 $category->updated_at = $data['updated_at'] ?? '';
120 $category->created_by = (int) ($data['created_by'] ?? 0);
121 $category->updated_by = (int) ($data['updated_by'] ?? 0);
122
123 return $category;
124 }
125
126 /**
127 * Convert to array
128 */
129 public function toArray(): array
130 {
131 return [
132 'id' => $this->id,
133 'label' => $this->label,
134 'slug' => $this->slug,
135 'description' => $this->description,
136 'age_min' => $this->age_min,
137 'age_max' => $this->age_max,
138 'pricing_mode' => $this->pricing_mode,
139 'min_pax' => $this->min_pax,
140 'max_pax' => $this->max_pax,
141 'group_overflow' => $this->group_overflow,
142 'icon' => $this->icon,
143 'status' => $this->status,
144 'created_at' => $this->created_at,
145 'updated_at' => $this->updated_at,
146 'created_by' => $this->created_by,
147 'updated_by' => $this->updated_by,
148 ];
149 }
150 }
151
152