PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.11 All 82 releases
yatra / app / Models / Destination.php

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

103 lines 2.1 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 * Destination Model
9 * Represents a destination entity
10 */
11 class Destination
12 {
13 /**
14 * @var int
15 */
16 public int $id;
17
18 /**
19 * @var string
20 */
21 public string $name;
22
23 /**
24 * @var string
25 */
26 public string $slug;
27
28 /**
29 * @var string
30 */
31 public string $description;
32
33 /**
34 * @var array|null Icon data (type and value)
35 */
36 public ?array $icon;
37
38 /**
39 * @var string
40 */
41 public string $status;
42
43 /**
44 * @var string
45 */
46 public string $created_at;
47
48 /**
49 * @var string
50 */
51 public string $updated_at;
52
53 /**
54 * @var int
55 */
56 public int $created_by;
57
58 /**
59 * @var int
60 */
61 public int $updated_by;
62
63 /**
64 * Create from array
65 */
66 public static function fromArray(array $data): self
67 {
68 $destination = new self();
69
70 $destination->id = (int) ($data['id'] ?? 0);
71 $destination->name = $data['name'] ?? '';
72 $destination->slug = $data['slug'] ?? '';
73 $destination->description = $data['description'] ?? '';
74 $destination->icon = isset($data['icon']) ? (is_array($data['icon']) ? $data['icon'] : maybe_unserialize($data['icon'])) : null;
75 $destination->status = $data['status'] ?? 'draft';
76 $destination->created_at = $data['created_at'] ?? '';
77 $destination->updated_at = $data['updated_at'] ?? '';
78 $destination->created_by = (int) ($data['created_by'] ?? 0);
79 $destination->updated_by = (int) ($data['updated_by'] ?? 0);
80
81 return $destination;
82 }
83
84 /**
85 * Convert to array
86 */
87 public function toArray(): array
88 {
89 return [
90 'id' => $this->id,
91 'name' => $this->name,
92 'slug' => $this->slug,
93 'description' => $this->description,
94 'icon' => $this->icon,
95 'status' => $this->status,
96 'created_at' => $this->created_at,
97 'updated_at' => $this->updated_at,
98 'created_by' => $this->created_by,
99 'updated_by' => $this->updated_by,
100 ];
101 }
102 }
103