Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f1ec06b

Browse files
test worked application :)
1 parent 971030a commit f1ec06b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

‎Application/Controllers/Home.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
use MVC\Controller;
4+
5+
class ControllersHome extends Controller {
6+
7+
public function index() {
8+
9+
// Connect to database
10+
$model = $this->model('home');
11+
12+
// Read All Task
13+
$users = $model->getAllUser();
14+
15+
// Prepare Data
16+
$data = ['data' => $users];
17+
18+
// Send Response
19+
$this->response->sendStatus(200);
20+
$this->response->setContent($data);
21+
}
22+
23+
public function post() {
24+
25+
if ($this->request->getMethod() == "POST") {
26+
// Connect to database
27+
$model = $this->model('home');
28+
29+
// Read All Task
30+
$users = $model->getAllUser();
31+
32+
// Prepare Data
33+
$data = ['data' => $users];
34+
35+
// Send Response
36+
$this->response->sendStatus(200);
37+
$this->response->setContent($data);
38+
}
39+
}
40+
}

‎Application/Models/Home.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
use MVC\Model;
4+
5+
class ModelsHome extends Model {
6+
7+
public function getAllUser() {
8+
// can you connect to database
9+
// $this->db->query( write your sql syntax: "SELECT * FROM " . DB_PREFIX . "user");
10+
11+
return [
12+
'name' => 'Mohammad',
13+
'family' => 'Rahmani',
14+
'age' => 21,
15+
'country' => 'Afghanistan',
16+
'city' => 'Herat'
17+
];
18+
}
19+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /