You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CommandsDataAccess.php 898B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App\Http\DataAccess;
  3. use Luticate\Utils\LuDataAccess;
  4. use App\Http\DataAccess\Models\Commands;
  5. use App\Http\DBO\CommandsDbo;
  6. class CommandsDataAccess extends LuDataAccess {
  7. protected static function getModel()
  8. {
  9. return new Commands();
  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("description", "ilike", "%" . $query . "%", "or")
  20. );
  21. }
  22. /**
  23. * @param $name
  24. * @return CommandsDbo|null
  25. */
  26. public static function getByName($name)
  27. {
  28. $sensor = Commands::where("name", "=", $name)->first();
  29. if (is_null($sensor)) {
  30. return null;
  31. }
  32. return $sensor->toDbo();
  33. }
  34. }