{"repo":"topclaudy/compoships","free":true,"listed":false,"github":"https://github.com/topclaudy/compoships","clone":"git clone https://github.com/topclaudy/compoships.git","description":"Multi-columns relationships for Laravel's Eloquent ORM","language":"PHP","stars":1204,"topics":["laravel","composite-keys","relationships","eloquent","multi-columns","multi-keys"],"license":"MIT","category":"databases-storage","readme_excerpt":"Compoships ========== Compoships offers the ability to specify relationships based on two (or more) columns in Laravel's Eloquent ORM. The need to match multiple columns in the definition of an Eloquent relationship often arises when working with third party or pre existing schema/database. The problem Eloquent doesn't support composite keys. As a consequence, there is no way to define a relationship from one model to another by matching more than one column. Trying to use where clauses (like in the example below) won't work when eager loading the relationship because at the time the relationship is processed $this- team id is null. Related discussions: Relationship on multiple keys Querying relations with extra conditions not working as expected Querying relations with extra conditions in Eager Loading not working BelongsTo relationship with 2 foreign keys Laravel Eloquent: multiple foreign keys for relationship Laravel hasMany association with multiple columns Installation The recommended way to install Compoships is through Composer Usage Using the Awobaz\\Compoships\\Database\\Eloquent\\Model class Simply make your model class derive from the Awobaz\\Compoships\\Database\\Eloquent\\Model base class. The Awobaz\\Compoships\\Database\\Eloquent\\Model extends the Eloquent base class without changing its core functionality. Using the Awobaz\\Compoships\\Compoships trait If for some reason you can't derive your models from Awobaz\\Compoships\\Database\\Eloquent\\Model , you may take advantage o","default_branch":null,"files":null,"tree":[],"storefront":"/r/topclaudy","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/topclaudy/compoships/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}