codesleeve / holloway
Holloway: A datamapper built on top of the Illuminate Database package.
Installs: 4 457
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: >= 8.1
- illuminate/database: ^8.0|^9.0|^10.0|^11.0
- illuminate/events: ^8.0|^9.0|^10.0|^11.0
- illuminate/pagination: ^8.0|^9.0|^10.0|^11.0
- laravel/legacy-factories: ^1.1
Requires (Dev)
- doctrine/instantiator: ~1.4.0
- fakerphp/faker: ^1.9.1
- mockery/mockery: ^1.4.2
- phpunit/phpunit: ^8.5.8|^9.3.3
- vlucas/phpdotenv: ^5.6
This package is auto-updated.
Last update: 2024-12-06 19:44:13 UTC
README
Holloway is a loose implementation of the datamapper pattern (Fowler). It's an ORM built on top of the illuminate/database
package, which is also the same package that powers Laravel's implemenation of Active Record: Eloquent. Because of this, a Holloway mapper can be used used to retrieve results from a database similar to how an Eloquent model is used. However, the Entities returned from it are completely decoupled from the underlying database and can be designed to work however you wish them to.
Why use this package?
Some day you may find yourself needing unbreakable domain objects (entities that are never allowed to exist in an invalid state) in your Laravel app. If you wish to query these using the same query builder syntax you know and love, Holloway may be of use to you.
Relationships
Custom Many Relationship Example
$this->customMany('stickyNotes', function ($query, Collection $clientServices) { return $query->from('sticky_notes') ->select('sticky_notes.*', 'client_service_sticky_notes.client_service_id') ->join('client_service_sticky_notes', 'sticky_notes.id', '=', 'client_service_sticky_notes.sticky_note_id') ->whereIn('client_service_sticky_notes.client_service_id', $clientServices->pluck('id')) ->get(); }, function (stdClass $clientService, stdClass $stickyNote) { return $clientService->id == $stickyNote->client_service_id; }, StickyNote::class);