ManyToMany Relationship on AttachAction
I am trying to use AttachAction, and I am trying to implement it. But instead i got an error
error:
model:
error:
Call to undefined method App\Models\Car\Feature::carOwners()Call to undefined method App\Models\Car\Feature::carOwners()model:
namespace App\Models\Car;
class Feature extends Model
{
public function carFeatures(): BelongsToMany
{
return $this->belongsToMany(CarOwner::class, 'car_features')
->withPivot(['is_active', 'remark'])
->withTimestamps();
}
}namespace App\Models\Car;
class Feature extends Model
{
public function carFeatures(): BelongsToMany
{
return $this->belongsToMany(CarOwner::class, 'car_features')
->withPivot(['is_active', 'remark'])
->withTimestamps();
}
}namespace App\Models;
class CarFeature extends Model
{
public function feature(): BelongsTo
{
return $this->belongsTo(CarSpec\Feature::class);
}
public function carOwner(): BelongsTo
{
return $this->belongsTo(CarOwner::class);
}
}namespace App\Models;
class CarFeature extends Model
{
public function feature(): BelongsTo
{
return $this->belongsTo(CarSpec\Feature::class);
}
public function carOwner(): BelongsTo
{
return $this->belongsTo(CarOwner::class);
}
}namespace App\Models;
class CarOwner extends Model
{
public function carFeatures(): BelongsToMany
{
return $this->belongsToMany(CarSpec\Feature::class, 'car_features')
->withPivot(['is_active', 'remark'])
->withTimestamps();
}
}namespace App\Models;
class CarOwner extends Model
{
public function carFeatures(): BelongsToMany
{
return $this->belongsToMany(CarSpec\Feature::class, 'car_features')
->withPivot(['is_active', 'remark'])
->withTimestamps();
}
}namespace App\Filament\Driver\Resources\CarOwnerResource\RelationManagers;
class CarFeaturesRelationManager extends RelationManager
{
protected static string $relationship = 'carFeatures';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
...
}),
])
->headerActions([
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
// ->form(fn (Tables\Actions\AttachAction $attachAction): array => [
// $attachAction->getRecordSelect(),
// Forms\Components\Select::make('name'),
// ]),
])
}
}namespace App\Filament\Driver\Resources\CarOwnerResource\RelationManagers;
class CarFeaturesRelationManager extends RelationManager
{
protected static string $relationship = 'carFeatures';
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
...
}),
])
->headerActions([
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
// ->form(fn (Tables\Actions\AttachAction $attachAction): array => [
// $attachAction->getRecordSelect(),
// Forms\Components\Select::make('name'),
// ]),
])
}
}