Sync fields determine which data from your models is synchronized to clients. Proper field selection is crucial for performance, security, and user experience.
Be mindful of field sizes to optimize sync performance:
Copy
class Article extends Model{ use Harmonics; public function getSyncFields(): array { $fields = [ 'id', 'title', 'excerpt', // ✅ Good: Short summary 'status', 'author_id', 'created_at', 'updated_at' // 'content' // ❌ Avoid: Large text field // 'raw_html' // ❌ Avoid: Even larger processed content ]; // Only include full content when specifically requested if ($this->shouldSyncFullContent()) { $fields[] = 'content'; } return $fields; } private function shouldSyncFullContent(): bool { // Include full content only in specific contexts return request()->routeIs('articles.show') || auth()->user()?->can('edit', $this); }}
You now understand how to effectively configure sync fields for optimal performance and security. Next, learn how to apply sync filters to control which records each user receives.