} }); /* delete anggota */ $app->delete('/restoran/:key', function ($key) use($app, $db) { $query = $db->restoran()->where("restoran_id", $key); if ($query->fetch()) { $result = $query->delete(); echo json_encode(array("status" => true, "message" => " restoran with id {$key} was deleted")); } else { echo json_encode(array("status" => false, "message" => "restoran with id {$key} does not exist")); } }); /*----------------------------------------------- table menu ------------------------------------------------------------------------*/ /* get menu */ $app->get('/menu', function () use($app, $db) { $query = $db->menu()->order("created_at desc"); foreach ($query as $value) { $result["status"] = true; $result["result"][] = array("menu_id" => $value["menu_id"], "restoran_id" => $value["restoran_id"], "menu_name" => $value["menu_name"], "menu_price" => $value["menu_price"], "menu_kode" => $value["menu_kode"], "menu_description" => $value["menu_description"], "menu_image" => $value["menu_image"], "menu_sku" => $value["menu_sku"], "created_at" => $value["created_at"]); } if ($query->count("*") > 0) { echo json_encode($result); } else { echo json_encode(array("status" => false, "message" => "nothing data yet")); } }); /* search menu */ $app->get('/menu/:key', function ($key) use($app, $db) { $query = $db->menu()->where("menu_name LIKE ?", "%{$key}%")->order("created_at desc"); foreach ($query as $value) { $result["status"] = true;