{"id":19943944,"url":"https://github.com/akiyamasm/lazybelongstomany","last_synced_at":"2025-07-30T08:11:04.152Z","repository":{"id":46293058,"uuid":"409617954","full_name":"akiyamaSM/LazyBelongsToMany","owner":"akiyamaSM","description":"A lightweight implementation of Laravel's belongs To many","archived":false,"fork":false,"pushed_at":"2021-11-01T17:17:02.000Z","size":15,"stargazers_count":24,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-07T17:53:18.710Z","etag":null,"topics":["eloquent","laravel","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akiyamaSM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-23T14:07:58.000Z","updated_at":"2023-11-12T22:14:26.000Z","dependencies_parsed_at":"2022-09-14T21:00:50.082Z","dependency_job_id":null,"html_url":"https://github.com/akiyamaSM/LazyBelongsToMany","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2FLazyBelongsToMany","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2FLazyBelongsToMany/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2FLazyBelongsToMany/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akiyamaSM%2FLazyBelongsToMany/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akiyamaSM","download_url":"https://codeload.github.com/akiyamaSM/LazyBelongsToMany/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252212068,"owners_count":21712536,"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":["eloquent","laravel","php"],"created_at":"2024-11-13T00:18:33.052Z","updated_at":"2025-05-03T15:33:26.487Z","avatar_url":"https://github.com/akiyamaSM.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LazyBelongsToMany\nA lightweight implementation of Laravel's belongs To many relationship in cases you don't need pivot table.\n\n## Installation\n\nFirst, install the package through Composer.\n```php\ncomposer require inani/lazy-belongs-to-many\n```\n\n### Usage\n\nSuppose we have the following database structure. A ``User`` can be linked to one or many ``Tag``. instead of creating the pivot table we can save tags id list in a column on the user table.\n````\n| id | name              | tags_id       |\n|----|-------------------|---------------|\n| 1  | El Houssain inani | [1, 10, 4, 33]|\n````\n\n````php\n\n\u003c?php\n\nnamespace Models;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Inani\\LazyBelongsToMany\\Relations\\BelongsToManyCreator;\n\nclass User extends Model\n{\n    use BelongsToManyCreator;\n    \n    protected $casts = [\n      'tags_id' =\u003e 'array' // \u003c=== IMPORTANT\n    ];\n    \n    \n    /**\n    * Tags\n     * @return mixed\n    */\n    public function tags()\n    {\n        return $this-\u003ebelongsToManyInArray(Tag::class);\n    }\n}\n````\n\nFor the time being there is no implementation for the inverse. I'll be happy to see your contribution at any way.\n\nHappy Coding.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Flazybelongstomany","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakiyamasm%2Flazybelongstomany","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakiyamasm%2Flazybelongstomany/lists"}