Code Monkey home page Code Monkey logo

eloquent-model-generator's People

Contributors

believer-ufa avatar heskyji avatar pepijnolivier avatar smskin avatar wpatrick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eloquent-model-generator's Issues

only specific tables won't work

If I use it with the following command (taken from help: "models:generate [options] [--] []"):
php artisan models:generate table1,table2,table3...

it still will generate all tables from database.

Also this still will generate all tables:
php artisan models:generate --tables=table1,table2,table3...

Class prefix/suffix

Hi,

Firstly thank you, the code works very well, especially regarding foreign-key relations.

It would be very handy for us if we could add a prefix/suffix to class names, so that we can isolate and distinguish our repository-pattern classes from actual business logic classes.
For example, if we have an Order class, it would be good to have an OrderRepository class that Order extends, so that we can separate the repo from the business logic.

Thank you!

Add to Packagist

hey @pepijnolivier

we should consider registering this generator to packagist.

and begin with tagging releases.

Would help!

Cheers Max

Command problem

Method User11001\EloquentModelGenerator\Console\GenerateModelsCommand::handle() does not exist

Self referencing foreign keys not generating valid models

After running the following migration, I get an invalid model generated.
I suggest the issue is in the looping logic in User11001\EloquentModelGenerator\Console\GenerateModelsCommand::addManyToManyRules()
Migration
`
Schema::create('boma_coa_categories', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->string('description');
$table->timestamps();
$table->softDeletes();
});

    Schema::create('boma_coa_codes', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('boma_account_code');
        $table->string('boma_account_name');
        $table->text('description');
        $table->string('boma_usage_type');
        $table->string('boma_account_header_code');
        $table->string('boma_account_header_name');
        $table->integer('parent_boma_coa_code_id')->unsigned();
        $table->integer('boma_coa_category_id')->unsigned();
        $table->string('boma_sorting');
        $table->string('boma_data_source');
        $table->string('version_num');
        $table->string('data_source');
        $table->timestamps();
        $table->softDeletes();
    });
    Schema::table('boma_coa_codes', function (Blueprint $table) {
        $table->foreign('boma_coa_category_id')->references('id')->on('boma_coa_categories');
        $table->foreign('parent_boma_coa_code_id')->references('id')->on('boma_coa_codes');
    });`

How I generate Models
php artisan models:generate --path="app/Models/ModelsBase" --overwrite --namespace="App\Models\ModelsBase"

Resulting model class
`<?php namespace App\Models\ModelsBase;

use Illuminate\Database\Eloquent\Model;

class BomaCoaCategory extends Model {
/**
* Generated
*/
protected $table = 'boma_coa_categories';
protected $fillable = ['id', 'name', 'description', 'deleted_at'];
public function bomaCoaCodes() {
return $this->belongsToMany(\App\Models\ModelsBase\BomaCoaCode::class, 'boma_coa_codes', 'boma_coa_category_id', 'parent_boma_coa_code_id');
}

// SHOULD BE
// public function bomaCoaCategory() {
// return $this->hasMany(\App\Models\ModelsBase\BomaCoaCategory::class, 'boma_coa_category_id', 'id');
//}
public function bomaCoaCodes() {
return $this->hasMany(\App\Models\ModelsBase\BomaCoaCode::class, 'boma_coa_category_id', 'id');
}
}`

Namespace not flexible

Hello,
I've run across a slight issue when using your otherwise very useful library.
When a user can specify the path for the location of the files to be created, using the APP_NAME or default App\Models namespace doesn't seem flexible enough to comply with PSR-4.

Could namespace be added as an option, so that a user can explicitly specify the model namespace and path when creating them?

Thanks.

duplicate name method

Hi,
After I generate, name method was dublicate
ex:

public function affiliateCustomerInvites() {
return $this->hasMany(\App\Models\AffiliateCustomerInvite::class, 'customer_id', 'id');
}
public function affiliateCustomerInvites() {
return $this->hasMany(\App\Models\AffiliateCustomerInvite::class, 'inviter_id', 'id');
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.