public function create()
 {
     if ($this->auth->guest()) {
         $this->app->flash("info", "You must be logged on to create a post");
         $this->app->redirect("/login");
     } else {
         $request = $this->app->request;
         $title = $request->post('title');
         $content = $request->post('content');
         $author = $_SESSION['user'];
         $date = date("dmY");
         $paydoc = $request->post('paydoc');
         $price = -10;
         $validation = new PostValidation($title, $author, $content, $paydoc);
         if ($validation->isGoodToGo()) {
             $post = new Post();
             $post->setAuthor($author);
             $post->setTitle($title);
             $post->setContent($content);
             $post->setDate($date);
             $post->setPayDoc($paydoc);
             if ($paydoc != 0) {
                 $this->userRepository->updateBalance($author, $price);
             }
             $savedPost = $this->postRepository->save($post);
             $this->app->redirect('/posts/' . $savedPost . '?msg="Post succesfully posted');
         }
     }
     $this->app->flashNow('error', join('<br>', $validation->getValidationErrors()));
     $this->app->render('createpost.twig');
 }