Eloquent-Model-Generator icon indicating copy to clipboard operation
Eloquent-Model-Generator copied to clipboard

duplicate name method

Open hoangnguyengia opened this issue 8 years ago • 1 comments

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'); }

hoangnguyengia avatar Sep 09 '16 07:09 hoangnguyengia

I'm experiencing the same error. The problem is in this code: https://github.com/pepijnolivier/Eloquent-Model-Generator/blob/v2.0.0/src/Console/GenerateModelsCommand.php#L247

It doesn't check to see if the name is already used for that class. If it did detect it's already used, I'm not sure what it should even do here? affiliateCustomerInvites1, affiliateCustomerInvites2, etc? That wouldn't be an intuitive ORM to use... I think it might make sense to have the more frequently accessed function / the one that makes logical sense. I'm doing this part by hand right now. Maybe at the minimum just emit a warning about those class names / function names?

james-coder avatar Sep 13 '16 22:09 james-coder