Adding token and current timestamp to html.

This commit is contained in:
2017-09-05 08:54:32 +07:00
parent 06c4e2a74e
commit 45dbe24da7
3 changed files with 17 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ namespace App\Controllers;
use \Core\View;
use App\Models\Post;
use \Core\Token;
class Posts
{
@@ -26,9 +27,13 @@ class Posts
public function entry()
{
$categories = $this->model->showCategories();
$date = new \DateTime();
$timestamp = $date->format('Y/m/d H:i:s');
// echo "You can entry new data here."; // Nanti di replace sama twig view ke App\Views\Data\entry_pengumuman.html
View::render('Data/entry_pengumuman.html', [
'categories' => $categories
'categories' => $categories,
'timestamp' => $timestamp,
'token' => Token::generate()
]);
return true;
}
@@ -37,6 +42,8 @@ class Posts
{
if ($id) {
$posts = $this->model->showSingle($id);
$date = new \DateTime();
$timestamp = $date->format('Y/m/d H:i:s');
// echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html
View::render(
'Data/edit_pengumuman.html',
@@ -46,7 +53,9 @@ class Posts
'created_at' => $posts['created_at'],
'creator' => $posts['creator'],
'edited_at' => $posts['edited_at'],
'editor' => $posts['editor']
'editor' => $posts['editor'],
'timestamp' => $timestamp,
'token' => Token::generate()
]
);
return true;