71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
class OrtApicontroller extends mfBaseApicontroller {
|
|
|
|
protected function init() {
|
|
//$this->addRoute("/home/getAll", "getHomes", "GET");
|
|
$this->addRoute("/ort/find", "findOrt", "POST");
|
|
//$this->addRoute("/home/:oanid/products", "getHomeProducts", "GET");
|
|
}
|
|
|
|
protected function findOrt() {
|
|
$search = $this->post['search'];
|
|
|
|
if(!$search) {
|
|
return mfResponse::BadRequest(['message' => "Suchbegriff darf nicht leer sein!"]);
|
|
}
|
|
|
|
$orte = [];
|
|
|
|
$ag = new ADBGemeinde();
|
|
$results = $ag->find($search);
|
|
//var_dump($results);exit;
|
|
foreach($results as $result) {
|
|
if(is_array($result->plz) && count($result->plz)) {
|
|
foreach($result->plz as $plz) {
|
|
$orte[] = ['plz' => $plz->plzstring, 'ort' => $result->name];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return mfResponse::Ok(['orte' => $orte]);
|
|
}
|
|
|
|
/*
|
|
protected function getHomes() {
|
|
$homes = [];
|
|
|
|
foreach(HomeModel::search(['operationalstate_id' => [5,3]]) as $home) {
|
|
$homes[] = $home->getApiArray();
|
|
}
|
|
|
|
return mfResponse::Ok(['homes' => $homes]);
|
|
}*/
|
|
/*
|
|
protected function validateOan($oan_id) {
|
|
$home = new Home();
|
|
$home->loadByOan($oan_id);
|
|
if(!$home->id) {
|
|
return mfResponse::NotFound(['oan_d' => $oan_id, 'isValid' => false]);
|
|
}
|
|
|
|
return mfResponse::Ok(['oan_d' => $oan_id, 'isValid' => true]);
|
|
}*/
|
|
/*
|
|
protected function getHomeProducts($oanid) {
|
|
$home = new Home();
|
|
$home->loadByOan($oanid);
|
|
if(!$home->id) {
|
|
return mfResponse::NotFound(['message' => "Home not found"]);
|
|
}
|
|
|
|
$products = [];
|
|
foreach(ProductModel::search(['provider_id' => $this->me->provider_id]) as $product) {
|
|
$products[] = $product->getApiArray();
|
|
}
|
|
|
|
return mfResponse::Ok(["products" => $products]);
|
|
|
|
}*/
|
|
} |