summaryrefslogtreecommitdiff
path: root/src/Controller/Card.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controller/Card.php')
-rw-r--r--src/Controller/Card.php31
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;
+ }
+}
+