Preload options limit from relation page

I have a relation page, and when I go to attach my relation, its all searcahable, but how can I add a preload with 5 records?
class ManageOrganisationProducts extends ManageRelatedRecords
{
protected static string $resource = OrganisationResource::class;

protected static string $relationship = 'products';

protected static ?string $navigationIcon = 'heroicon-o-square-3-stack-3d';

public static function getNavigationLabel(): string
{
return 'Products';
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Grid::make(1)
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\Toggle::make('enabled')
->required(),
]),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
])
->filters([])
->headerActions([
Tables\Actions\AttachAction::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DetachBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->modifyQueryUsing(fn(Builder $query) => $query->withoutGlobalScopes([
SoftDeletingScope::class,
]));
}
}
class ManageOrganisationProducts extends ManageRelatedRecords
{
protected static string $resource = OrganisationResource::class;

protected static string $relationship = 'products';

protected static ?string $navigationIcon = 'heroicon-o-square-3-stack-3d';

public static function getNavigationLabel(): string
{
return 'Products';
}

public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Grid::make(1)
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\Toggle::make('enabled')
->required(),
]),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
])
->filters([])
->headerActions([
Tables\Actions\AttachAction::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\DetachAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DetachBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->modifyQueryUsing(fn(Builder $query) => $query->withoutGlobalScopes([
SoftDeletingScope::class,
]));
}
}
3 Replies
Jamie Cee
Jamie Cee2mo ago
bump
Jamie Cee
Jamie Cee2mo ago
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
Tables\Actions\AttachAction::make()
->preloadRecordSelect(),
Nah, dropdown is still empty
Want results from more Discord servers?
Add your server