-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollers.php
More file actions
41 lines (35 loc) · 856 Bytes
/
controllers.php
File metadata and controls
41 lines (35 loc) · 856 Bytes
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
<?php
/**
* ------------------------ Controllers ------------------------
*/
class HomeController
{
/**
* @var array|string[][]
*/
public array $menus = [
'menus' => [
'home' => 'Home',
'about_us' => 'About us',
'contact' => 'Contact'
]
];
/**
* @param array $data
* @return string[]
*/
#[Router(path: '/menus', method: Router::GET)]
public function index(array $data): array
{
return $this->menus;
}
#[Router(path: '/menus/update', method: Router::PUT | Router::PATCH)]
public function update(array $data): array
{
if (! isset($data['name'])) {
return ['message' => 'Menu was not found'];
}
$this->menus['menus'][$data['name']] = $data['value'];
return $this->menus;
}
}