Skip to content

Laravel Artisan Make Model command for Mongo Model using Jenssegers/MongoDb

License

Notifications You must be signed in to change notification settings

TilakPutta-zz/laravel-make-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Artisan Make Model (Mongo)

Release GitHub license Donate

A Composer Package written to generate boiler-plate code of Mongo Model with Jenssegers/MongoDb using Laravel Artisan

Table of contents

Installation

Installation using composer:

composer require tilakputta/laravel-make-mongo

And add the command to commands array in Kernel.php

protected $commands = [
    \TilakPutta\Console\ModelMakeCommand::class
];

Usage

For usage with Artisan type in this command:

php artisan make:model ModelName

Examples

php artisan make:model Models/PermissionRole

creates app/Models/PermissionRole.php

<?php

namespace App\Models;

use Jenssegers\Mongodb\Eloquent\Model;

class PermissionRole extends Model
{
    protected $collection = 'permission_roles';

    protected $fillable = [
        
    ];

    protected $primaryKey = 'id';

    public $incrementing = false;

    /**
     * model life cycle event listeners
     */
    public static function boot(){
        parent::boot();

        static::creating(function ($instance){
            if (!$instance->exists) {
                $instance->id = uniqid();
            }
        });

        static::created(function ($instance){
            
        });
    }
}

Authors

TilakPutta

Contributing

Please make your contributions to make it more useful.