12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
-
- namespace App\Http\DataAccess;
-
- use Luticate\Utils\LuDataAccess;
- use App\Http\DataAccess\Models\Sensors;
- use App\Http\DBO\SensorsDbo;
-
- class SensorsDataAccess extends LuDataAccess {
- protected static function getModel()
- {
- return new Sensors();
- }
-
- protected static function getOrderBy()
- {
- return array(array("name", "ASC"));
- }
-
- protected static function getQueryPredicate($query)
- {
- return array(
- array("name", "ilike", "%" . $query . "%", "or"),
- array("description", "ilike", "%" . $query . "%", "or")
- );
- }
-
- /**
- * @param $name
- * @return SensorsDbo|null
- */
- public static function getByName($name)
- {
- $sensor = Sensors::where("name", "=", $name)->first();
- if (is_null($sensor)) {
- return null;
- }
- return $sensor->toDbo();
- }
- }
|