public function create()
 {
     if ($this->auth->guest()) {
         $this->app->flash("info", "You must be logged on to register a patent");
         $this->app->redirect("/login");
     } else {
         $request = $this->app->request;
         $title = $request->post('title');
         $description = $request->post('description');
         $company = $request->post('company');
         $date = date("dmY");
         $file = $this->startUpload();
         $validation = new PatentValidation($title, $description);
         if ($validation->isGoodToGo()) {
             $patent = new Patent($company, $title, $description, $date, $file);
             $patent->setCompany($company);
             $patent->setTitle($title);
             $patent->setDescription($description);
             $patent->setDate($date);
             $patent->setFile($file);
             $savedPatent = $this->patentRepository->save($patent);
             $this->app->redirect('/patents/' . $savedPatent . '?msg="Patent succesfully registered');
         }
     }
     $this->app->flashNow('error', join('<br>', $validation->getValidationErrors()));
     $this->app->render('patents/new.twig');
 }
 public function makePatentFromRow(array $row)
 {
     $patent = new Patent($row['patentId'], $row['company'], $row['title'], $row['description'], $row['date'], $row['file']);
     $patent->setPatentId($row['patentId']);
     $patent->setCompany($row['company']);
     $patent->setTitle($row['title']);
     $patent->setDescription($row['description']);
     $patent->setDate($row['date']);
     $patent->setFile($row['file']);
     return $patent;
 }