Filament Manage Related with hasMany and hasMany with Repeater

I have 3 tables : "Process", "Units" and "UnitsItems"
process
id - integer
name - string
number_process - float
hasMany
units - process_id
units
id - integer
name - string
process_id - integer
address - string
hasMany
items_units - units_id

items_units
id - integer
name - string
value - float
units_id - integer
process
id - integer
name - string
number_process - float
hasMany
units - process_id
units
id - integer
name - string
process_id - integer
address - string
hasMany
items_units - units_id

items_units
id - integer
name - string
value - float
units_id - integer
The problem is that when I create a new unit, I must add 1 (or more) itemsunits that are connected to a unit, through the "repeater". A unit can be linked to 1 or many unit items. But when I try to add some unit items it has the following error.
Call to a member function itemsUnits() on null
Call to a member function itemsUnits() on null
[1]: https://i.stack.imgur.com/8MaxL.png Full code through the link https://stackoverflow.com/questions/77886833/filament-manage-related-with-hasmany-and-hasmany-with-repeater UnitsRelationManager.php :
class UnitsRelationManager extends ManageRelatedRecords
{
protected static string $resource = ProcessResource::class;
protected static string $relationship = 'units';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('address')
->required()
->maxLength(150),
Forms\Components\Section::make('Items')
->schema([
Forms\Components\Repeater::make('Items')
->relationship('itemsUnits')->label("")
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('value')
->required(),
])->minItems(1)
]),
]);
}

...
}
class UnitsRelationManager extends ManageRelatedRecords
{
protected static string $resource = ProcessResource::class;
protected static string $relationship = 'units';

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('address')
->required()
->maxLength(150),
Forms\Components\Section::make('Items')
->schema([
Forms\Components\Repeater::make('Items')
->relationship('itemsUnits')->label("")
->schema([
Forms\Components\TextInput::make('name')
->required(),
Forms\Components\TextInput::make('value')
->required(),
])->minItems(1)
]),
]);
}

...
}
Stack Overflow
Filament Manage Related with hasMany and hasMany with Repeater
I will write my problem I have 3 tables : "Process", "Units" and "UnitsItems" process id - integer name - string number_process - float hasMany ...
No description
0 Replies
No replies yetBe the first to reply to this messageJoin