} }); /* delete anggota */ $app->delete('/anggota/:key', function ($key) use($app, $db) { $query = $db->anggota->where("id", $key); if ($query->fetch()) { $result = $query->delete(); echo json_encode(array("status" => true, "message" => "cek with id {$key} was deleted")); } else { echo json_encode(array("status" => false, "message" => "tes id {$key} does not exist")); } }); /*--------------------------------------------------- table restoran ----------------------------------------------------------------*/ /* get restoran */ $app->get('/restoran', function () use($app, $db) { $query = $db->restoran()->order("created_at desc"); foreach ($query as $value) { $result["status"] = true; $result["result"][] = array("restoran_id" => $value["restoran_id"], "restoran_name" => $value["restoran_name"], "restoran_logo" => $value["restoran_logo"], "restoran_address" => $value["restoran_address"], "created_at" => $value["created_at"], "updated_at" => $value["updated_at"]); } if ($query->count("*") > 0) { echo json_encode($result); } else { echo json_encode(array("status" => false, "message" => "nothing data yet")); } }); /* seacrh restoran */ $app->get('/restoran/:key', function ($key) use($app, $db) { $query = $db->restoran()->where("restoran_name LIKE ?", "%{$key}%")->order("created_at desc"); foreach ($query as $value) { $result["status"] = true;