chaoswd / laravel-mongo-models
A lightweight Laravel package that adds an Artisan command for generating MongoDB Eloquent models using the official mongodb/laravel driver.
Installs: 3
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/chaoswd/laravel-mongo-models
Requires
- php: ^8.2
- laravel/framework: ^10.0|^11.0|^12.0
- mongodb/laravel: ^4.0
README
A lightweight Laravel package that adds an Artisan command for generating MongoDB Eloquent models...
๐ Installation
You can install the package via Composer:
composer require chaoswd/laravel-mongo-models
Tested on Laravel 12.x.
Likely compatible with Laravel 10 and 11, but unverified. Requires themongodb/laraveldriver installed.
โ๏ธ Usage
Generate a MongoDB model using the custom Artisan command:
php artisan make:mongo:model {name} --collection="collectionName"
Example
php artisan make:mongo:model User --collection="users"
This command will create a model at:
app/Models/User.php
with the following structure:
<?php namespace App\Models; use MongoDB\Laravel\Eloquent\Model; class User extends Model { protected $connection = 'mongodb'; protected $collection = 'users'; protected $guarded = []; }
๐งฉ Features
- ๐น Generates MongoDB-compatible Eloquent models
- ๐น Uses the official
mongodb/laraveldriver - ๐น Automatically sets
connectionandcollectionproperties - ๐น Simple, framework-native syntax
๐งฐ Requirements
- PHP 8.2+
- Laravel 12.*
mongodb/laravel
๐งพ License
This package is open-sourced software licensed under the MIT License.
ยฉ Jordan Gerber DBA Chaos Web Development
๐ Changelog
See the CHANGELOG.md for version history and release notes.
๐ฌ Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss your ideas.
Please make sure to update tests as appropriate.
Created with ๐ by Chaos Web Development