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