Standardmethoden für Standort und News.Events erweitert
This commit is contained in:
43
Controller/NewsController.php
Normal file
43
Controller/NewsController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Blog\Controller;
|
||||
|
||||
use Blog\Model\NewsModel;
|
||||
|
||||
class NewsController {
|
||||
|
||||
protected $view;
|
||||
protected $newsModel;
|
||||
|
||||
public function __construct($view) {
|
||||
$this->newsModel = new NewsModel();
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function showNews() {
|
||||
$news = $this->newsModel->getNews();
|
||||
$this->view->setVars([
|
||||
"news" => $news
|
||||
]);
|
||||
}
|
||||
|
||||
public function createNews() {
|
||||
$news = [
|
||||
"name" => $_POST['name'],
|
||||
"beschreibung" => $_POST['beschreibung'],
|
||||
"datum" => $_POST['datum']
|
||||
];
|
||||
$this->newsModel->createNews($news);
|
||||
$this->view->setVars([
|
||||
"name" => $_POST['name']
|
||||
]);
|
||||
}
|
||||
|
||||
public function deleteNews() {
|
||||
$newsId = $_POST['newsid'];
|
||||
$this->newsModel->deleteNews($newsId);
|
||||
$this->view->setVars([
|
||||
"deleted" => $newsId
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user