diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-01-10 20:29:04 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-01-10 20:29:04 +0100 |
commit | a319f3a419790925bed539ba141038c72a83e70f (patch) | |
tree | dfb24183cc693863df733e190dbbc6da93bb82e5 /src/Controller/Card.php |
Initial commit
Diffstat (limited to 'src/Controller/Card.php')
-rw-r--r-- | src/Controller/Card.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/Controller/Card.php b/src/Controller/Card.php new file mode 100644 index 0000000..39560bb --- /dev/null +++ b/src/Controller/Card.php @@ -0,0 +1,31 @@ +<?php + +namespace Elements\Controller; + +use Elements\DB; +use Elements\Model\Card as CardModel; +use Elements\Model\CardMeta; +use Symfony\Component\HttpFoundation\RedirectResponse; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +class Card +{ + public static function add(Request $request) + { + $card = new CardModel(); + + foreach ($request->get('meta') as $key => $value) { + $meta = new CardMeta($key, $value); + $card->addMeta($meta); + DB::save($meta); + } + + DB::save($card); + + $response = new RedirectResponse('/'); + + return $response; + } +} + |