DictApi.php 481 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace app\common\api;
  3. use app\common\model\Dict;
  4. /**
  5. * Description of DictApi
  6. *
  7. * @author sgq
  8. */
  9. class DictApi {
  10. public static function selectByParentCode($code) {
  11. $parent = Dict::where("code", $code)->findOrEmpty()->toArray();
  12. $dictList = Dict::where("pid", $parent["id"])->select()->toArray();
  13. $tmp = [];
  14. foreach ($dictList as $dict) {
  15. $tmp[$dict["code"]] = $dict["name"];
  16. }
  17. return $tmp;
  18. }
  19. }