Updated mithril to do as it has to do
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user