What replace HasRelationshipTable in v3?

In v2 i have this piece of code in many of my relationship manager classes
->headerActions([
CreateAction::make()
->using(fn (HasRelationshipTable $livewire, array $data): Model => $livewire
->getRelationship()
->create($data)),
]);
->headerActions([
CreateAction::make()
->using(fn (HasRelationshipTable $livewire, array $data): Model => $livewire
->getRelationship()
->create($data)),
]);
But in v3 i get HasRelationshipTable doesn't exist errors. So what is the new way of doing it? I checked the documentation but couldn't figure it out Thank you
1 Reply
pocket.racer
pocket.racerOP15mo ago
Full code of the class in question
<?php

namespace App\Filament\Resources\OfficeResource\RelationManagers;

use App\Filament\Resources\OfficeBranchResource;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Contracts\HasRelationshipTable;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;

class OfficeBranchRelationManager extends RelationManager
{
protected static string $relationship = 'officeBranches';

protected static ?string $recordTitleAttribute = 'id';

/**
* @throws \Exception
*/
public function form(Form $form): Form
{
return $form->schema(OfficeBranchResource::getFormSchema());
}

/**
* @throws \Exception
*/
public function table(Table $table): Table
{
return $table
->columns(OfficeBranchResource::getTableColumns())
->actions([
EditAction::make(),
DeleteAction::make(),
])
->headerActions([
CreateAction::make()
->using(fn (HasRelationshipTable $livewire, array $data): Model => $livewire
->getRelationship()
->create($data)),
]);
}
}
<?php

namespace App\Filament\Resources\OfficeResource\RelationManagers;

use App\Filament\Resources\OfficeBranchResource;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Actions\CreateAction;
use Filament\Tables\Actions\DeleteAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Contracts\HasRelationshipTable;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Model;

class OfficeBranchRelationManager extends RelationManager
{
protected static string $relationship = 'officeBranches';

protected static ?string $recordTitleAttribute = 'id';

/**
* @throws \Exception
*/
public function form(Form $form): Form
{
return $form->schema(OfficeBranchResource::getFormSchema());
}

/**
* @throws \Exception
*/
public function table(Table $table): Table
{
return $table
->columns(OfficeBranchResource::getTableColumns())
->actions([
EditAction::make(),
DeleteAction::make(),
])
->headerActions([
CreateAction::make()
->using(fn (HasRelationshipTable $livewire, array $data): Model => $livewire
->getRelationship()
->create($data)),
]);
}
}
Want results from more Discord servers?
Add your server