-
Notifications
You must be signed in to change notification settings - Fork 288
Description
- Laravel Version: 8.52
- PHP Version: 7.4.21
- Blueprint Version: dev-master
- Platform: Windows
Issue:
Hi @jasonmccreary!
I'm using blueprint dev-master on my project, and I noticed #477 (e446a41 commit) introduced a bug.
The bug happens when you use blueprint config models_namespace
, and you have a .blueprint
generated with trace
command.
So to reproduce the issue you'll need to;
- Set
'models_namespace' => 'Models',
on blueprint config. - Run the Tracer command to generate the
.blueprint
- The following
draft-yaml
;
draft.yaml:
models:
Post:
id
icon_id: foreign:icons.id
timestamps
This draft.yaml
will generate the following relationship;
public function icon()
{
return $this->belongsTo(\App\Models\Models\Icon::class, 'icon_id');
}
Note the double Models
on namespace.
Although the problem was introduced on that commit, I believe that commit is not the problem. That commit actually fixes a problem with modelForContext
function.
What I believe to be the problem is the Trace
command, because it will wrongly (I assume) generate incorrect paths when models_namespace
config is set.
This is a .blueprint
file generated with Trace
command;
models:
Models\Address: { street: 'string nullable', country: string, icon_id: 'integer nullable', monster_id: integer }
Models\Icon: { name: string, icon: string }
when I run the above yaml, the .blueprint is populated with;
models:
Models\Address: { street: 'string nullable', country: string, icon_id: 'integer nullable', monster_id: integer }
Models\Icon: { name: string, icon: string }
Post: { icon_id: 'integer unsigned' }
The entries generated with trace
command are relative to app
, even when models_namespace
config is set.
The entries generated with build
are relative to models_namespace
.
The entries should be relative to models_namespace
.
Before #477, since that function was not working there was an "hack" on Tracer
function relativeClassName
to avoid this issue, by removing that, everything works as expected. I'll submit a PR to aim that.