Function edit works successfuly
This commit is contained in:
parent
c64064321e
commit
61060dd393
@ -42,12 +42,15 @@ class Posts
|
|||||||
$id = implode('', $id);
|
$id = implode('', $id);
|
||||||
$posts = $this->model->showSingle($id);
|
$posts = $this->model->showSingle($id);
|
||||||
$categories = $this->model->showCategories();
|
$categories = $this->model->showCategories();
|
||||||
|
$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
|
// 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(
|
View::render(
|
||||||
'Data/edit_pengumuman.html',
|
'Data/edit_pengumuman.html',
|
||||||
[
|
[
|
||||||
'posts' => $posts,
|
'posts' => $posts,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
|
'timestamp' => $timestamp,
|
||||||
'token' => Token::generate()
|
'token' => Token::generate()
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@ -65,4 +68,15 @@ class Posts
|
|||||||
return $this->index();
|
return $this->index();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function put($args = [])
|
||||||
|
{
|
||||||
|
$table = 'pengumuman';
|
||||||
|
$id = $args['id'];
|
||||||
|
unset($args['id']);
|
||||||
|
if ($this->model->update($table, $args, $id)) {
|
||||||
|
Session::flash('info', 'Data successfuly updated');
|
||||||
|
return $this->index();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,28 +16,47 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label for="konten">Konten: </label>
|
<label for="content">Konten: </label>
|
||||||
<textarea name="konten" rows="3" cols="30">{{ post.content }}</textarea>
|
<textarea name="content" rows="3" cols="30">{{ post.content }}</textarea>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label for="created_at">Dibuat pada: </label>
|
<label>Dibuat pada: </label>
|
||||||
<input type="text" name="created_at" value="{{ post.created_at }}" readonly>
|
<span>{{ post.created_at }}</span>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label for="creator">Dibuat oleh: </label>
|
<label>Dibuat oleh: </label>
|
||||||
<input type="text" name="creator" value="{{ post.creator }}" readonly>
|
<span>{{ post.creator }}</span>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label for="edited_at">Diubah pada: </label>
|
<label for="expired_at">Berlaku sampai: </label>
|
||||||
<input type="text" name="edited_at" value="{{ post.edited_at }}" readonly>
|
<span>{{ post.expired_at }}</span>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<label for="editor">Diubah oleh: </label>
|
<label>Diubah pada: </label>
|
||||||
<input type="text" name="editor" value="{{ post.editor }}" readonly>
|
<span>
|
||||||
|
{% if post.edited_at == "0000-00-00 00:00:00" %}
|
||||||
|
Tidak pernah
|
||||||
|
{% else %}
|
||||||
|
{{ post.edited_at }}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<input type="hidden" name="edited_at" value="{{ timestamp }}">
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<label for="editor_name">Diubah oleh: </label>
|
||||||
|
<span>
|
||||||
|
{% if post.editor == "0" %}
|
||||||
|
-
|
||||||
|
{% else %}
|
||||||
|
{{ post.editor }}
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
<input type="hidden" name="editor" value="3"><!-- User -->
|
||||||
|
|
||||||
<!-- Current Timestamp -->
|
<!-- Current Timestamp -->
|
||||||
<input type="hidden" name="_currts" value="{{ timestamp }}" disabled>
|
<input type="hidden" name="_currts" value="{{ timestamp }}" disabled>
|
||||||
@ -51,6 +70,6 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<button type="submit" name="edit">Edit</button>
|
<button type="submit">Edit</button>
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -82,7 +82,7 @@ class Router
|
|||||||
unset($var['_method']);
|
unset($var['_method']);
|
||||||
}
|
}
|
||||||
if (array_key_exists('id', $this->params)) {
|
if (array_key_exists('id', $this->params)) {
|
||||||
$var[] = $this->params['id'];
|
$var['id'] = $this->params['id'];
|
||||||
}
|
}
|
||||||
if (isset($var)) {
|
if (isset($var)) {
|
||||||
return $object->$action($var);
|
return $object->$action($var);
|
||||||
|
Loading…
Reference in New Issue
Block a user