Updated mithril to do as it has to do

This commit is contained in:
2017-09-28 11:43:28 +07:00
parent 7c61498047
commit b704e2f1a7
2 changed files with 32 additions and 29 deletions

View File

@@ -1,31 +1,34 @@
<?php
namespace App\Controllers;
use Core\Token;
use App\Models\Post;
class Api
{
public function posts() {
$get = [
'data' => [
[
'id' => 1,
'judul' => 'post_1',
'status' => 1
],
[
'id' => 2,
'judul' => 'post_2',
'status' => 0
],
[
'id' => 3,
'judul' => 'post_3',
'status' => 2
]
]
];
private $model;
public function __construct() {
$this->model = new Post();
}
public function posts() {
$get = [];
$get['count'] = 0;
$get['data'] = $this->model->showJoin([
['pengumuman.status', '=', 1]
]);
if (array_key_exists(0, $get['data']) == false) {
$temp_data = $get['data'];
unset($get['data']);
$get['data'][] = $temp_data;
$temp_data = [];
}
if ($get['data'] != false) {
$get['count'] = count($get['data']);
}
$get['count'] = count($get['data']);
header('Content-Type: application/json');
echo json_encode($get);
}