New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

shomisha/unusual-relationships

This package offers a trait which provides your models with the ability to have relationships not included within standard Laravel installations.
1,041 8
Install
composer require shomisha/unusual-relationships
Latest Version:1.0.1
PHP:~7.0
Laravel:5 · 6
License:MIT
Last Updated:Sep 16, 2019
Links: GitHub  ·  Packagist
Maintainer: shomisha

Laravel Unusual Relationships

Latest Stable Version Software License Build Status StyleCI Scrutinizer Code Quality

This package is meant to provide its users with an API to accessing relationships that aren't included in Laravel's base installation. It achieves this effect by utilizing a trait which in turn instantiates custom relationship classes which rely on Laravel's relationship scaffolding.

class Employee extends Model {
    public function tasks() 
    {
        return $this->belongsToMany(Task::class);
    }
    
    public function boss() 
    {
        return $this->belongsTo(Boss::class);
    }
}

class Boss extends Model {
    use Shomisha\UnusualRelationships\HasUnusualRelationships;

    public function employees() 
    {
        return $this->hasMany(Employee::class);
    }
    
    public function tasks()
    {
        return $this->belongsToManyThrough(Task::class, Employee::class)
    }
}

The example above shows how you can use the belongsToManyThrough relationship to connect your model to its distantly related models. To learn more about this which methods work with which database structures, as well as how to use those methods, head over to our wiki pages.

Related Packages

laragear/meta-model

Let other developers customize your package model and migrations

2,003,720 1
tusimo/embed-relation

a relation for laravel

10,942 3
pdphilip/opensearch

An OpenSearch implementation of Laravel's Eloquent ORM

467,689 0
designmynight/laravel-elasticsearch

Use Elasticsearch as a database in Laravel to retrieve Eloquent models and perfo...

45,415 30
friendsofcat/laravel-couchbase

A Couchbase based Eloquent model and Query builder for Laravel

31,058 14

Version History

Version Released PHP Laravel License
1.0.1 ~7.0 >=5.6 MIT
1.0.0 ~7.0 ~5.6 MIT