Download the PHP package tassawartech174/mongodb-relations without Composer
On this page you can find all versions of the php package tassawartech174/mongodb-relations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download tassawartech174/mongodb-relations
More information about tassawartech174/mongodb-relations
Files in tassawartech174/mongodb-relations
Download tassawartech174/mongodb-relations
More information about tassawartech174/mongodb-relations
Files in tassawartech174/mongodb-relations
Vendor tassawartech174
Package mongodb-relations
Short Description Custom Laravel Eloquent relationships for MongoDB using jenssegers/mongodb and mongodb/laravel-mongodb. Supports unidirectional many-to-many and reverse lookups for embedded and reference-based relations.
License MIT
Package mongodb-relations
Short Description Custom Laravel Eloquent relationships for MongoDB using jenssegers/mongodb and mongodb/laravel-mongodb. Supports unidirectional many-to-many and reverse lookups for embedded and reference-based relations.
License MIT
Please rate this library. Is it a good library?
Informations about the package mongodb-relations
MongoDB Relations for Laravel
Custom unidirectional many-to-many relationship support for MongoDB in Laravel.
📦 Installation
Requires PHP 7.4+ and Laravel 6.x – 11.x.
⚙️ Configuration
If you want to customize the default local key used in relations, publish the package config file:
Or use this command:
- This will publish:
config/mongodb-relations.php
🚀 Usage
Step 1: Use the Trait
In your Eloquent model (e.g. User), use the provided trait:
use TassawarTech174\MongodbRelations\Traits\MongodbRelations;
class User extends Model
{
use MongodbRelations;
public function roles()
{
return $this->manyToManyRelation(Role::class, 'role_ids');
}
}
Or use relation like:
use TassawarTech174\MongodbRelations\Traits\MongodbRelations;
class User extends Model
{
use MongodbRelations;
public function roles()
{
return $this->manyToManyRelation(Role::class);
}
}
Step 3: Relationship Methods
- Get related models:
$user->roles;
- Attach related models:
$user->roles()->attach(['id1', 'id2']);
- Detach related models:
$user->roles()->detach(['id1']);
- Sync related models:
$user->roles()->sync(['id1', 'id3']);
- Models where relations:
$user->whereRelationField('roles', 'name', 'operater', 'search value);
$user->orWhereRelationField('roles', 'name', 'operater', 'search value);
✅ Supported Laravel Versions
-
Laravel 6.x
-
Laravel 7.x
-
Laravel 8.x
-
Laravel 9.x
-
Laravel 10.x
- Laravel 11.x
🔐 License
This package is open-source software licensed under the MIT license.
All versions of mongodb-relations with dependencies
PHP Build Version
Package Version
The package tassawartech174/mongodb-relations contains the following files
Loading the files please wait ...