Relation Manager with Parameters

I have a Relation Manager with parameters (level)
<?php

namespace App\Filament\Resources\Assessment\AssessmentManagerResource\RelationManagers;

use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\;
use Illuminate\Database\Eloquent\Builder;

class QuestionsRelationManager extends RelationManager
{
protected static string $relationship = 'Questions';
protected static ?string $recordTitleAttribute = 'title';

public int $level;

public function mount($level)
{
$this->level = $level;
}

......

/**
* @throws \Exception
*/
protected function getTableQuery(): Builder
{
return parent::getTableQuery()->where('level_id', $this->level);
}
}
<?php

namespace App\Filament\Resources\Assessment\AssessmentManagerResource\RelationManagers;

use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\;
use Illuminate\Database\Eloquent\Builder;

class QuestionsRelationManager extends RelationManager
{
protected static string $relationship = 'Questions';
protected static ?string $recordTitleAttribute = 'title';

public int $level;

public function mount($level)
{
$this->level = $level;
}

......

/**
* @throws \Exception
*/
protected function getTableQuery(): Builder
{
return parent::getTableQuery()->where('level_id', $this->level);
}
}
i want to pass this parameters
public static function getRelations(): array
{
$list=[];
for ($i = 1; $i <= 10; $i++) {
$list[]= app(QuestionsRelationManager::class, [
'level' => $i,
]);
}
return $list;
}
public static function getRelations(): array
{
$list=[];
for ($i = 1; $i <= 10; $i++) {
$list[]= app(QuestionsRelationManager::class, [
'level' => $i,
]);
}
return $list;
}
I try,but it's not work i get this error Filament\Resources\Pages\EditRecord::Filament\Resources\Pages\Concerns\{closure}(): Argument #1 ($manager) must be of type Filament\Resources\RelationManagers\RelationGroup|string, App\Filament\Resources\Assessment\AssessmentManagerResource\RelationManagers\QuestionsRelationManager given
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server