{"id":16676320,"url":"https://github.com/wolfy-j/lodm","last_synced_at":"2025-03-21T18:31:46.799Z","repository":{"id":57081647,"uuid":"43818351","full_name":"wolfy-j/lodm","owner":"wolfy-j","description":"ODM with inheritance and OOP composition for Laravel 5+","archived":false,"fork":false,"pushed_at":"2017-08-02T20:07:26.000Z","size":101,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-13T13:10:01.968Z","etag":null,"topics":["laravel","mongodb","odm","php","spiral"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wolfy-j.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-07T13:41:06.000Z","updated_at":"2022-08-17T12:56:56.000Z","dependencies_parsed_at":"2022-08-24T14:42:48.703Z","dependency_job_id":null,"html_url":"https://github.com/wolfy-j/lodm","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolfy-j%2Flodm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolfy-j%2Flodm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolfy-j%2Flodm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wolfy-j%2Flodm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wolfy-j","download_url":"https://codeload.github.com/wolfy-j/lodm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221817487,"owners_count":16885551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","mongodb","odm","php","spiral"],"created_at":"2024-10-12T13:10:06.579Z","updated_at":"2024-10-28T10:34:36.966Z","avatar_url":"https://github.com/wolfy-j.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["Database/Eloquent/Models"],"readme":"ODM with inheritance and OOP composition for Laravel 5+\n========\n[![Latest Stable Version](https://poser.pugx.org/spiral/odm/v/stable)](https://packagist.org/packages/spiral/odm) \n[![License](https://poser.pugx.org/spiral/odm/license)](https://packagist.org/packages/spiral/odm)\n[![Build Status](https://travis-ci.org/spiral/odm.svg?branch=master)](https://travis-ci.org/spiral/odm)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/spiral/odm/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/spiral/odm/?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/spiral/odm/badge.svg?branch=master)](https://coveralls.io/github/spiral/odm?branch=master)\n\n\u003cb\u003e[Full Documentation](http://spiral-framework.com/guide)\u003c/b\u003e | [CHANGELOG](https://github.com/spiral/odm/blob/master/CHANGELOG.md)\n\nLODM module is intended to bring the Spiral ODM component functionality into your Laravel applications. This component provides the ability to manage your MongoDB data in an OOP way using your models compositions and aggregations.\n\n## Installation\nPackage installation can be performed using the simple composer command \n`$ composer require wolfy-j/lodm`. \n\nTo include ODM functionality in your application, you have to register the service provider  `Spiral\\LODM\\Laravel\\ODMServiceProvider` and CLI command `Spiral\\LODM\\Commands\\SchemaUpdate` in the app.php configure and `ConsoleKernel` accordingly. \n\nThe module provides two configuration files which describe the class location directories (by default whole application), the set of connected MongoDB databases (ODM does not use any of Laravel's database functionality) and options that can simplify document creation.\n\n## Documentation\n* [MongoDB Databases](https://spiral-framework.com/guide/odm/databases.md)\n* [Documents and DocumentEntity](https://spiral-framework.com/guide/odm/entities.md)\n* [Accessors and Filters](https://spiral-framework.com/guide/odm/accessors.md)\n* [Repositories and Selectors](https://spiral-framework.com/guide/odm/repositories.md)\n* [Scaffolding](https://spiral-framework.com/guide/odm/scaffolding.md)\n* [Compositions and Aggregations](https://spiral-framework.com/guide/odm/oop.md)\n* [Inheritance](https://spiral-framework.com/guide/odm/inheritance.md)\n\n## Examples\n```php\nclass User extends Document\n{\n  const SCHEMA = [\n    '_id'            =\u003e \\MongoId::class,\n    'name'           =\u003e 'string',\n    'email'          =\u003e 'string',\n    'balance'        =\u003e 'float',\n    'timeRegistered' =\u003e \\MongoDate::class,\n    'tags'           =\u003e ['string'],\n    'profile'        =\u003e Profile::class,\n\n    //Aggregations\n    'posts'          =\u003e [\n        self::MANY =\u003e Post::class,\n        ['userId' =\u003e 'self::_id']\n    ]\n  ];\n}\n```\n\n```php\nprotected function indexAction()\n{\n    $u = new User();\n    $u-\u003ename = 'Anton';\n    $u-\u003eemail = 'test@email.com';\n    $u-\u003ebalance = 99;\n    $u-\u003esave();\n\n    dump($u);\n}\n```\n\n```php\nprotected function indexAction(string $id, UsersRepository $users)\n{\n    $user = $users-\u003efindByPK($id);\n    if (empty($user)) {\n        throw new NotFoundException('No such user');\n    }\n\n    dump($user);\n}\n```\n\n```php\n$user = User::findOne();\n$user-\u003eprofile-\u003ebiography = 'some bio';\n$user-\u003eprofile-\u003efacebookUID = 2345678;\n\n$user-\u003esessions-\u003esolidState(false);\n$user-\u003esessions-\u003epush(new Session([\n    'timeCreated' =\u003e new \\MongoDate(),\n    'accessToken' =\u003e 'newrandom'\n]));\n```\n\n\n## Issues\nPlease do not open issue tickets in this github project unless they are related to the integration process. Use [Primary Respository](https://github.com/spiral/odm) for ODM related issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfy-j%2Flodm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolfy-j%2Flodm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolfy-j%2Flodm/lists"}