Georgi Arnaudov
Georgi Arnaudov
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
Glad you found the issue! Keep it up mate.
17 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
Thats the repeater
Repeater::make('locations')
->visible(fn ($get) => $get('type') === 'offer')
->relationship()
->label('Междинни спирки')
->helperText('')
->minItems(1)
->defaultItems(1)
->schema([
...
]),
Repeater::make('locations')
->visible(fn ($get) => $get('type') === 'offer')
->relationship()
->label('Междинни спирки')
->helperText('')
->minItems(1)
->defaultItems(1)
->schema([
...
]),
17 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
@n3b0r Sure, you just have to add a HasMany to a model that represents the pivot.
public function locations(): HasMany
{
return $this->hasMany(AdLocation::class);
}
public function locations(): HasMany
{
return $this->hasMany(AdLocation::class);
}
17 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
Right after I posted my second answer tried with a HasMany as you just suggested. Works like a charm! Thanks for you time!
17 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
@Dan Harrin Sorry to bother you again, but I slept on the issue and figured that HasMany may not be appropriate. The reason is that I have predefined Locations and want to attach multiple to the Ad. For me, that would be done with a pivot table holding the ad_id and the location_ekatte. I think the problem is in the naming of the fields in the pivot table.
17 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
Lol, im such a dummy, thanks
17 replies