Georgi Arnaudov
Georgi Arnaudov
FFilament
Created by Georgi Arnaudov on 2/9/2024 in #❓┊help
How to reorder many to many by pivot attribute?
I'm using spatie/sortable and want to reorder records after one is detached. Is there a way to achieve this without pivot model?
2 replies
FFilament
Created by Georgi Arnaudov on 6/1/2023 in #❓┊help
BelongsToMany relationship in Repeater
Hey, I've got two models - Ad & Location. The Location model uses a custom primary key $table->string('ekatte')->primary();. Those are both relationships:
// Location
public function ads(): BelongsToMany
{
return $this->belongsToMany(Ad::class);
}

// Ad
public function locations(): BelongsToMany
{
return $this->belongsToMany(Location::class);
}
// Location
public function ads(): BelongsToMany
{
return $this->belongsToMany(Ad::class);
}

// Ad
public function locations(): BelongsToMany
{
return $this->belongsToMany(Location::class);
}
When trying to edit an Ad and insert more records using a Repeater with a relationship set, it fails with an error that the property location_ekatte must be added to the $fillable array in the Location model. That property doesn't even exist there... You can check the attached file. I really appreciate any help you can provide.
17 replies