Esempio n. 1
0
 protected function actionDelete()
 {
     $id = $_GET['id'] ?? false;
     $this->redirectIf('/admin/news/index', false === $id);
     $article = \App\Models\News::findByID($id);
     $this->redirectIf('/admin/news/index', $article->delete());
 }
Esempio n. 2
0
 protected function actionShow()
 {
     $id = $_GET['id'] ?: false;
     $this->redirectIf('/admin/news/index', false === $id);
     if (false === ($article = \App\Models\News::findByID($id))) {
         throw new \App\Exceptions\NotFound($_SERVER['REQUEST_URI']);
     }
     $this->view->twigDisplay('article.html.twig', ['article' => $article]);
 }
Esempio n. 3
0
<?php

use App\Models\News;
require __DIR__ . '/../../autoload.php';
$id = isset($_GET['id']) ? $_GET['id'] : false;
$act = isset($_GET['act']) ? $_GET['act'] : false;
if (false === $id && false === $act) {
    header('Location: /');
}
// DELETE
if ($act == 'delete') {
    $news = News::findByID($id);
    $news->delete();
    header('Location: /');
}
// UPDATE
if ($act == 'update') {
    $news = News::findByID($id);
    include __DIR__ . '/../Views/Admin/update.php';
}
// ADD
if ($act == 'add') {
    include __DIR__ . '/../Views/Admin/add.php';
}