Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 35 |
| App\Models\OrderReview | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
42 | |
0.00% |
0 / 35 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getInstance | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 5 |
|||
| insertForm | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 15 |
|||
| insertCart | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 13 |
|||
| <?php | |
| namespace App\Models; | |
| use App\Models\DatabaseMySql; | |
| class OrderReview { | |
| private static $instance; | |
| private $db; | |
| public function __construct() { | |
| $this->db = DatabaseMySql::getInstance(); | |
| } | |
| public static function getInstance() { | |
| if (!self::$instance) { | |
| self::$instance = new OrderReview(); | |
| } | |
| return self::$instance; | |
| } | |
| /** | |
| * | |
| * @param array $formularData | |
| * @return | |
| */ | |
| public function insertForm($formularData, $cartTotal) { | |
| $sql = 'INSERT INTO `order` (Mail, Vorname, Nachname, Straße , Hausnummer , Land , Stadt, Postleitzahl, orderValue) VALUES | |
| (:Mail, :Vorname , :Nachname , :Strasse , :Hausnummer , :Land , :Stadt, :Postleitzahl, :orderValue)'; | |
| $placeholders = [ | |
| 'Mail' => $formularData['E-Mail'], | |
| 'Vorname' => $formularData['Vorname'], | |
| 'Nachname' => $formularData['Nachname'], | |
| 'Strasse' => $formularData['Straße'], | |
| 'Hausnummer' => $formularData['Hausnummer'], | |
| 'Land' => $formularData['Land'], | |
| 'Stadt' => $formularData['Stadt'], | |
| 'Postleitzahl' => $formularData['Postleitzahl'], | |
| 'orderValue' => $cartTotal | |
| ]; | |
| $this->db->insert($sql, $placeholders); | |
| } | |
| public function insertCart($articles, $orderId) { | |
| foreach ($articles->getArticles() as $article) { | |
| $sql = 'INSERT INTO `order_single` (fk_order_id ,product_id, productName, productQuantity, productPrice) VALUES | |
| (:fk_order_id, :product_id , :productName , :productQuantity , :productPrice)'; | |
| $placeholders = [ | |
| 'fk_order_id' => $orderId, | |
| 'product_id' => $article->getID(), | |
| 'productName' => $article->getName(), | |
| 'productQuantity' => $article->getQuantity(), | |
| 'productPrice' => $article->getPrice() | |
| ]; | |
| $this->db->insert($sql, $placeholders); | |
| } | |
| } | |
| } |