Feb 23, 2023
0
Level 6
Laravel Spark for Stripe limitation
Hi Everybody,
As you know laravel spark for stripe let us to have only one billable class. In my app there is user model (individuals) and organizations that will have membership. There is a one-to-many relation between user and Organization. User can belongs to one organization and organization can have many users. What is the best way to model such a use case. I can have one table and store both organizations and users together. or have an entity table that has polymorphic relation with organization and user. Or any other idea that you can suggest.
class User extends Model
{
public function organization()
{
return $this->belongsTo(Organization::class);
}
public function entity()
{
return $this->morphOne(Entity::class, 'entity');
}
}
class Organization extends Model
{
public function users()
{
return $this->hasMany(User::class);
}
public function entity()
{
return $this->morphOne(Entity::class, 'entity');
}
}
class Entity extends Model
{
public function entity()
{
return $this->morphTo();
}
}
Please or to participate in this conversation.