1
0

Add berichten page, and authentication checks

This commit is contained in:
2017-03-30 19:36:22 +02:00
parent 4f47ae6a55
commit 516ced5152
7 changed files with 130 additions and 7 deletions

View File

@ -0,0 +1,57 @@
<?php
/**
* Informatica Eindproject D4p
* 6in3, Stedelijk Gymnasium Nijmegen
* Docent: Hans de Wolf
*
* ==================
*
* Daniel Boutros,
* Christiaan Goossens,
* Jelmer Hinssen
*/
namespace Inforbank\Application\Helper;
use Inforbank\Application;
class Berichten
{
public static function getUserBerichten()
{
$container = Application::getContainer();
$db = $container->db;
$berichten = $db->berichten->where('klantid', $container->auth->getUserID())->order('datum DESC');
$berichtArray = array();
foreach ($berichten as $bericht) {
$datum = new \DateTime($bericht['datum']);
$datum = $datum->format('d-m-Y');
$berichtArray[] = array(
"afzender" => $bericht['afzender'],
"bericht" => $bericht['bericht'],
"datum" => $datum
);
}
return $berichtArray;
}
public static function newBericht($user, $afzender, $bericht)
{
$container = Application::getContainer();
$db = $container->db;
$array = array(
'klantid' => (int) $user,
'afzender' => $afzender,
'bericht' => $bericht,
'datum' => date('Y-m-d')
);
$row = $db->berichten->insert($array);
}
}