Repeater not saving pivot relationship

I've been searching the docs, the filament repo, and discord all day and have found people with similar issues, but none of the fixes are working. For some reason the repeater data just will not save. The repeater is defined as:
Repeater::make('userEvents')
->relationship()
->model(CalendarEvent::class)
->schema([
Select::make('user_id')
->relationship('user','name'),
Select::make('user_role')
->enum(EventUserRole::class)
->options(EventUserRole::class),
DateTimePicker::make('remind_at')
->seconds(false),
])
Repeater::make('userEvents')
->relationship()
->model(CalendarEvent::class)
->schema([
Select::make('user_id')
->relationship('user','name'),
Select::make('user_role')
->enum(EventUserRole::class)
->options(EventUserRole::class),
DateTimePicker::make('remind_at')
->seconds(false),
])
using the pivot model UserEvent:
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function calendarEvent(): BelongsTo
{
return $this->belongsTo(CalendarEvent::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function calendarEvent(): BelongsTo
{
return $this->belongsTo(CalendarEvent::class);
}
One thing I've noticed is that in the edit page, Repeater.php:1095 will run this query:
SELECT * FROM `user_events` WHERE `user_events`.`calendar_event_id` IS NULL and `user_events`.`calendar_event_id` IS not NULL
SELECT * FROM `user_events` WHERE `user_events`.`calendar_event_id` IS NULL and `user_events`.`calendar_event_id` IS not NULL
4 Replies
awcodes
awcodes6mo ago
Why are you providing a model to the repeater, shouldn’t the relationship handle that.?
ZeroCharistmas
ZeroCharistmasOP6mo ago
The form schema is also used in a modal from the saade/filament-fullcalendar plugin and the repeater in the modal gives a
Call to a member function userEvents() on null
Call to a member function userEvents() on null
error without it. Commenting it out still doesn't help with the saving issue in the regular edit and create pages for the resource though, so I don't think that's the issue.
gladjanus43
gladjanus436mo ago
Your repeater is not having a relationship, userEvents is not a relationship on your model right?
ZeroCharistmas
ZeroCharistmasOP6mo ago
userEvents is a hasMany relationship on my model. The table also has a unique id. I should also mention that when an entry in the pivot table is created manually, it does not display in the repeater in the edit page. So the model function did end up being a pretty big part of it, which is a little weird because I thought I tested it out pretty thoroughly before. I'm just experiencing problems with the fullcalendar widget being unable to load the relationship for the create modal now.
Want results from more Discord servers?
Add your server