{"repo":"MrPunyapal/laravel-extended-relationships","free":true,"listed":false,"github":"https://github.com/MrPunyapal/laravel-extended-relationships","clone":"git clone https://github.com/MrPunyapal/laravel-extended-relationships.git","description":"Package provides additional, more efficient relationship methods for Laravel Eloquent models.","language":"PHP","stars":175,"topics":["belongsto","belongstomany","eloquent","hasmany","hasone","laravel","php","relationships"],"license":"MIT","category":"databases-storage","readme_excerpt":"laravel-extended-relationships Requirements - PHP: ^8.2 ^8.3 ^8.4 ^8.5 - Laravel: ^11.0 ^12.0 ^13.0 What is a need of extended relationships? The laravel-extended-relationships package provides additional, more efficient relationship methods for Laravel Eloquent models. The package offers several useful features such as reducing the number of database queries, improving performance, and minimizing duplicate code. I faced issue and made my own relationships then realize if I can use packages from open source then I can make one too and made this package. Installation You can install the package via composer: Laravel Boost This package ships a Laravel Boost skill named laravel-extended-relationships-development for on-demand guidance when working with these custom relationship helpers. If your Laravel application uses Boost, install Boost and publish its resources: If Boost is already installed and you add this package later, ask Boost to discover new package skills: Usage First, include the HasExtendedRelationships trait in your model: Next, define the BelongsToManyKeys relationship with the belongsToManyKeys method: This method takes three arguments: The related model ( User::class ) The foreign key ( id ) An array mapping the related table's foreign key names to the corresponding relation names on the model ( ['created by' = 'creator', ...] ) Then, you can fetch data from the auditors relationship like so: This allows you to define multiple relationships with just one method","default_branch":null,"files":null,"tree":[],"storefront":"/r/MrPunyapal","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/MrPunyapal/laravel-extended-relationships/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."}