Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Models\FreeIPA; |
| 4 | |
| 5 | use LdapRecord\Connection; |
| 6 | use LdapRecord\Models\Entry as BaseEntry; |
| 7 | use LdapRecord\Models\FreeIPA\Scopes\AddEntryUuidToSelects; |
| 8 | use LdapRecord\Models\Types\FreeIPA; |
| 9 | use LdapRecord\Query\Model\FreeIpaBuilder; |
| 10 | |
| 11 | /** @mixin FreeIpaBuilder */ |
| 12 | class Entry extends BaseEntry implements FreeIPA |
| 13 | { |
| 14 | /** |
| 15 | * The attribute key that contains the models object GUID. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | protected $guidKey = 'ipauniqueid'; |
| 20 | |
| 21 | /** |
| 22 | * The default attributes that should be mutated to dates. |
| 23 | * |
| 24 | * @var array |
| 25 | */ |
| 26 | protected $defaultDates = [ |
| 27 | 'krblastpwdchange' => 'ldap', |
| 28 | 'krbpasswordexpiration' => 'ldap', |
| 29 | ]; |
| 30 | |
| 31 | /** |
| 32 | * @inheritdoc |
| 33 | */ |
| 34 | protected static function boot() |
| 35 | { |
| 36 | parent::boot(); |
| 37 | |
| 38 | // Here we'll add a global scope to all FreeIPA models to ensure the |
| 39 | // Entry UUID is always selected on each query. This attribute is |
| 40 | // virtual, so it must be manually selected to be included. |
| 41 | static::addGlobalScope(new AddEntryUuidToSelects()); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Create a new query builder. |
| 46 | * |
| 47 | * @param Connection $connection |
| 48 | * |
| 49 | * @return FreeIpaBuilder |
| 50 | */ |
| 51 | public function newQueryBuilder(Connection $connection) |
| 52 | { |
| 53 | return new FreeIpaBuilder($connection); |
| 54 | } |
| 55 | } |