-
Notifications
You must be signed in to change notification settings - Fork 288
Closed
Labels
communityenhancementNew feature or requestNew feature or requestin progressThis issue is being worked on.This issue is being worked on.
Description
Hi, amazing work by the way!
Current situation
Reviewing the docs I can see that you can specify belongsToMany
relationships like so:
# draft.yaml
models:
User:
...
relationships:
belongsToMany: Store
This will generate something similar to the following method in the User
model:
# User.php
public function stores()
{
return $this->belongsToMany(Store::class);
}
But, currently, there's no way to customize the pivot table name: store_user
Proposal
It could be possible to pass an attribute when specifying the relationship to customize the pivot table:
models:
User:
...
relationships:
belongsToMany: Store:favorites
Generating:
# User.php
public function stores()
{
return $this->belongsToMany(Store::class, 'favorites');
}
Even further, in case you specify the pivot colum as a PascalCase word, this could generate the pivot model and configure it in the related models:
#draft.yaml
models:
User:
...
relationships:
belongsToMany: Store:Favorite
# User.php
public function stores()
{
return $this->belongsToMany(Store::class)->using(Favorite::class);
}
Metadata
Metadata
Assignees
Labels
communityenhancementNew feature or requestNew feature or requestin progressThis issue is being worked on.This issue is being worked on.