您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

HostsDataAccess.php 866B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Http\DataAccess;
  3. use Luticate\Utils\LuDataAccess;
  4. use App\Http\DataAccess\Models\Hosts;
  5. use App\Http\DBO\HostsDbo;
  6. class HostsDataAccess extends LuDataAccess {
  7. protected static function getModel()
  8. {
  9. return new Hosts();
  10. }
  11. protected static function getOrderBy()
  12. {
  13. return array(array("name", "ASC"));
  14. }
  15. protected static function getQueryPredicate($query)
  16. {
  17. return array(
  18. array("name", "ilike", "%" . $query . "%", "or"),
  19. array("url", "ilike", "%" . $query . "%", "or")
  20. );
  21. }
  22. /**
  23. * @param $name
  24. * @return HostsDbo|null
  25. */
  26. public static function getByName($name)
  27. {
  28. $host = Hosts::where("name", "=", $name)->first();
  29. if (is_null($host)) {
  30. return null;
  31. }
  32. return $host->toDbo();
  33. }
  34. }