count() ?: null; } public static function getMountCheckboxList(Get $get): CheckboxList { $allowedMounts = Mount::all(); $node = $get('node_id'); $egg = $get('egg_id'); if ($node && $egg) { $allowedMounts = $allowedMounts->filter(fn (Mount $mount) => ($mount->nodes->isEmpty() || $mount->nodes->contains($node)) && ($mount->eggs->isEmpty() || $mount->eggs->contains($egg)) ); } return CheckboxList::make('mounts') ->label('') ->relationship('mounts') ->live() ->options(fn () => $allowedMounts->mapWithKeys(fn ($mount) => [$mount->id => $mount->name])) ->descriptions(fn () => $allowedMounts->mapWithKeys(fn ($mount) => [$mount->id => "$mount->source -> $mount->target"])) ->helperText(fn () => $allowedMounts->isEmpty() ? trans('admin/server.no_mounts') : null) ->bulkToggleable() ->columnSpanFull(); } public static function getPages(): array { return [ 'index' => Pages\ListServers::route('/'), 'create' => Pages\CreateServer::route('/create'), 'edit' => Pages\EditServer::route('/{record}/edit'), ]; } public static function getEloquentQuery(): Builder { $query = parent::getEloquentQuery(); return $query->whereHas('node', function (Builder $query) { $query->whereIn('id', auth()->user()->accessibleNodes()->pluck('id')); }); } }