user(); if (! $user instanceof User) { return $query->whereRaw('1 = 0'); } return $query ->whereNull('archived_at') ->whereIn('id', function ($subQuery) use ($user): void { $subQuery->from('workspace_memberships') ->select('workspace_id') ->where('user_id', $user->getKey()); }); } public static function form(Schema $schema): Schema { return $schema ->schema([ Forms\Components\TextInput::make('name') ->required() ->maxLength(255), Forms\Components\TextInput::make('slug') ->required() ->maxLength(255) ->unique(ignoreRecord: true), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name') ->searchable() ->sortable(), Tables\Columns\TextColumn::make('slug') ->searchable() ->sortable(), ]) ->actions([ Actions\ViewAction::make(), Actions\EditAction::make(), ]); } public static function getPages(): array { return [ 'index' => Pages\ListWorkspaces::route('/'), 'create' => Pages\CreateWorkspace::route('/create'), 'view' => Pages\ViewWorkspace::route('/{record}'), 'edit' => Pages\EditWorkspace::route('/{record}/edit'), ]; } public static function getRelations(): array { return [ WorkspaceMembershipsRelationManager::class, ]; } }