-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.php
More file actions
53 lines (51 loc) · 1.58 KB
/
model.php
File metadata and controls
53 lines (51 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
class User{
public int $id;
public string $name;
public string $photo = "none.png";
public int $sub = 0;
public int $post = 0;
public function __construct(array | null $data = null){
if(isset($data)){
$this->id = $data["id"];
$this->name = $data["name"];
if(isset($data["photo"])){
$this->photo = $data["photo"];
}
$this->sub = $data["sub"];
$this->post = $data["post"];
}
}
}
class Post{
public int $id;
public Post | null $father;
public array $children;
public int $like;
public bool $liked;
public int $comment;
public string | null $text;
public string | null $photo;
public int $date;
public User $user;
public function __construct(array $data, bool $get_father = false, int $list_children = 0){
$this->id = $data["id"];
$this->comment = $data["comment"];
$this->text = $data["text"];
$this->photo = $data["photo"];
$this->date = $data["date"];
$this->like = $data["like"];
$this->liked = isset($data["liker"]);
$this->user = new User();
$this->user->id = $data["user_id"];
$this->user->name = $data["user_name"];
if(isset($data["user_photo"])){
$this->user->photo = $data["user_photo"];
}
if($get_father){
$this->father = getPostFather($data["answer"]);
}
$this->children = getPostChild($this->id, $list_children);
}
}
?>