Reputation: 21
Am creating a Laravel Filament application. I have Services and Offices tables. I tried creating a many-to-many relationship using office_service table. I keep getting this error Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsToMany::getOwnerKeyName() when i use that relationship in my ServiceResource
This is my migration
public function up(): void
{
Schema::create('office_service', function (Blueprint $table) {
$table->unsignedBigInteger('office_id')->nullable();
$table->unsignedBigInteger('service_id')->nullable();
});
}
On my Service Model
public function offices()
{
return $this->belongsToMany(Office::class, 'office_service');
}
On my Office Model
public function services()
{
return $this->belongsToMany(Service::class, 'office_service');
}
On my filament ServiceResource this is what I have
Select::make('offices')
->relationship('offices', 'name')
->preload()
->searchable()
->columnSpan(2),
What am I not doing right?
Upvotes: 1
Views: 784