You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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();
});
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');
}
}`
The text was updated successfully, but these errors were encountered:
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();
});
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');
}
}`
The text was updated successfully, but these errors were encountered: