I encountered a strange bug when creating a purchase or sale in the app.
Hi friends, My multitenancy application has the logic of buying and selling, but in order to perform these actions, you need to create a warehouse. The mistake is that the warehouse created in the first company can be used in another company, but it should be so that the warehouse belongs only to the company where it was created. CompanyPurchaseResource.php (form):
public static function form(Form $form): Form
{
return $form
->schema([
Select::make('warehouse_id')
->relationship('warehouse', 'name')
->prefixIcon('heroicon-o-wallet')
->required(),
Select::make('plan_account_id')
->relationship('planAccount','name')
->prefixIcon('heroicon-o-document')
->searchable()
->required(),
Forms\Components\TextInput::make('name')
->required()
->placeholder('Software purchase')
->minLength(1)
->prefixIcon('heroicon-o-user')
->maxLength(255),
Forms\Components\TextInput::make('quantity')
->required()
->placeholder('10')
->prefixIcon('heroicon-o-rectangle-stack')
->minLength(1)
->numeric(),
Forms\Components\TextInput::make('price')
->required()
->numeric()
->placeholder('100')
->minLength(1)
->prefix('$'),
Forms\Components\TextInput::make('summary')
->required()
->placeholder('1000')
->minLength(1)
->prefix('$')
->numeric(),
]);
} public static function form(Form $form): Form
{
return $form
->schema([
Select::make('warehouse_id')
->relationship('warehouse', 'name')
->prefixIcon('heroicon-o-wallet')
->required(),
Select::make('plan_account_id')
->relationship('planAccount','name')
->prefixIcon('heroicon-o-document')
->searchable()
->required(),
Forms\Components\TextInput::make('name')
->required()
->placeholder('Software purchase')
->minLength(1)
->prefixIcon('heroicon-o-user')
->maxLength(255),
Forms\Components\TextInput::make('quantity')
->required()
->placeholder('10')
->prefixIcon('heroicon-o-rectangle-stack')
->minLength(1)
->numeric(),
Forms\Components\TextInput::make('price')
->required()
->numeric()
->placeholder('100')
->minLength(1)
->prefix('$'),
Forms\Components\TextInput::make('summary')
->required()
->placeholder('1000')
->minLength(1)
->prefix('$')
->numeric(),
]);
}
