Updated mithril index to do (almost) the same with normal index

This commit is contained in:
2017-09-30 13:42:34 +07:00
parent 49310f645a
commit ae762758fc
6 changed files with 1506 additions and 39 deletions

View File

@@ -2,19 +2,38 @@
namespace App\Controllers;
use App\Models\Post;
use Core\Session;
class Api
{
private $model;
public function __construct() {
public function __construct()
{
$this->model = new Post();
}
public function posts() {
public function posts($args = ['id' => '1'])
{
$get = [];
$get['count'] = 0;
$get['data'] = $this->model->showJoin();
if ($args['id'] == 3) {
$get['data'] = $this->model->showJoin();
} else {
$get['data'] = $this->model->showJoin([
['pengumuman.status', '=', $args['id']]
]);
}
if ($get['data'] == false) {
$get['data']['content'] = 'Tidak ada pengumuman';
$get['data']['valid_at'] = '';
$get['data']['expired_at'] = '';
$get['data']['status'] = 0;
$get['data']['background'] = '#333';
$get['data']['foreground'] = '#888';
}
if (array_key_exists(0, $get['data']) == false) {
$temp_data = $get['data'];