45 lines
1.0 KiB
PHP
45 lines
1.0 KiB
PHP
<?php
|
|
namespace App\Controllers;
|
|
|
|
use Core\View;
|
|
use App\Models\Access;
|
|
use Core\Token;
|
|
use Core\Session;
|
|
use Core\Redirect;
|
|
|
|
class Home
|
|
{
|
|
private $access;
|
|
public function __construct()
|
|
{
|
|
$this->access = new Access();
|
|
}
|
|
public function index()
|
|
{
|
|
// echo "This is index of home"; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html
|
|
$posts = new Posts();
|
|
$posts->index();
|
|
return true;
|
|
}
|
|
|
|
public function login()
|
|
{
|
|
// echo "You have to login"; // Nanti di replace sama twig view ke App\Views\Access\login.html
|
|
View::render('Access/login.html', [
|
|
'token' => Token::generate()
|
|
]);
|
|
return true;
|
|
}
|
|
|
|
public function put($args = [])
|
|
{
|
|
if ($this->access->login($args)) {
|
|
$table = 'user';
|
|
$id = Session::get('userid');
|
|
if ($this->access->update($table, ['status' => 1], $id)) {
|
|
Redirect::to('/');
|
|
}
|
|
}
|
|
}
|
|
}
|