Attach relation manager
Hello, I am little bit confused in relationships. π
Can somebody help me with this please?
I have EventResource in it OrganizersRelationManager in it i want to attach and deattach organizers(which has model Customer).
Error: https://flareapp.io/share/o7A9Gqj7
Code OrganizesRelationManager:
class OrganizersRelationManager extends RelationManager
{
protected static string $relationship = 'organizers';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
])
->filters([
//
])
->headerActions([
Tables\Actions\AttachAction::make(),
])
->actions([
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DetachBulkAction::make(),
]),
]);
}
}
Relationship in event:
public function organizers()
{
return $this->belongsToMany(Customer::class,'event_organizer', 'event_id', 'customer_id');
}
Relationship in Customer:
public function organizers()
{
return $this->belongsToMany(Event::class,'event_organizer', 'customer_id', 'event_id');
}
Flare
Call to undefined method App\Models\Customer::events() - The error occurred at http://localhost/admin/events/3/edit
0 Replies