global $db; $product_category = ''; foreach ($db->types() as $product_type) { if ($product_type['id'] == $p['type_id']) { $product_category = $product_type['type_name']; } } // array_push($data,$usages_area); // $data[] = array('product_id' => $p['id'], 'product_brand' => $p['product_brand'], 'product_name' => $p['product_name'], 'product_category' => $product_category, 'product_type_id' => $p['type_id'], 'product_desc' => $p['product_desc'], 'product_img' => $p['product_img'], 'product_url' => $p['product_url'], 'product_material' => $p['product_material'], 'product_size' => $p['product_size'], 'product_application' => $p['product_application'], 'product_look' => $p['product_look'], 'product_finish_type' => $p['product_finish_type'], 'product_usages' => $usages_area, 'product_designs' => $designs, 'product_subtypes' => $subtypes, 'product_surface_types' => $surface_types, 'product_colors' => $colors, 'product_features' => $features, 'product_price' => $p['product_price'], 'product_rating' => $p['product_rating'], 'product_supplierID' => $p['supplierID'], 'product_isDiscountAvailable' => $p['isDiscountAvailable'], 'product_isProductAvailable' => $p['isProductAvailable']); } return $data; } function findSupplierDetails($query) { $supplierData = array(); $p = $query->fetch(); $supplierData[] = array('supplier_firstname' => $p['contactFirstName'], 'supplier_lastname' => $p['contactLastName'], 'supplier_titlename' => $p['contactTitle'], 'supplier_address' => $p['address'], 'supplier_city' => $p['city'], 'supplier_postal_code' => $p['postalcode'], 'supplier_state' => $p['state'], 'supplier_country' => $p['country'], 'supplier_contact_no' => $p['contactNo'], 'supplier_email' => $p['email'], 'supplier_company_name' => $p['companyName'], 'supplier_payment_method' => $p['paymentMethods']); return $supplierData; } /* Get all colors */ $app->get('/shiningfloor/colors', function () use($app, $db) { $colors = array(); foreach ($db->colors() as $color) { $colors[] = $color['color_name']; } $data[] = array('product_colors' => $colors); $app->response()->header('content-type', 'application/json'); echo json_encode(array('colors' => $data)); }); $app->run();