From 39e446ca8c1547fa561106cb030ac0afaa151695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Wed, 1 Oct 2025 04:14:32 -0300 Subject: [PATCH] Enhance documentation for Filament 4.x import rules and universal translation system. Added guidelines for table actions, form components, and translation methods, ensuring clarity on correct usage and implementation. Updated translation workflow and helper functions for better integration in models. --- .cursorrules | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/.cursorrules b/.cursorrules index cb20757..948defd 100644 --- a/.cursorrules +++ b/.cursorrules @@ -50,6 +50,82 @@ php artisan make:filament-resource ModelName --generate --model --migration --fa - Table column'ları için header'ları localization'dan al - Validation mesajları için localization kullan +### Filament 4.x Import Kuralları (ÖNEMLİ!) + +#### **Table Actions (DOĞRU):** +```php +// Table Actions için +use Filament\Actions\EditAction; +use Filament\Actions\DeleteAction; +use Filament\Actions\RestoreAction; +use Filament\Actions\ForceDeleteAction; + +// Bulk Actions için +use Filament\Actions\BulkActionGroup; +use Filament\Actions\DeleteBulkAction; +use Filament\Actions\ForceDeleteBulkAction; +use Filament\Actions\RestoreBulkAction; + +// Filters için +use Filament\Tables\Filters\TrashedFilter; +use Filament\Tables\Filters\SelectFilter; + +// Columns için +use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Columns\IconColumn; +use Filament\Tables\Columns\ImageColumn; + +// Table metodları +$table + ->recordActions([ // ✅ Doğru + EditAction::make(), + ]) + ->toolbarActions([ // ✅ Doğru + BulkActionGroup::make([ + DeleteBulkAction::make(), + ]), + ]); +``` + +#### **Form & Schema Components (DOĞRU):** +```php +// Form input components +use Filament\Forms\Components\TextInput; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\Checkbox; +use Filament\Forms\Components\Toggle; +use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\DateTimePicker; +use Filament\Forms\Components\FileUpload; + +// Layout components (ÖNEMLİ: Schemas namespace!) +use Filament\Schemas\Components\Section; // ✅ Doğru +use Filament\Schemas\Components\Grid; // ✅ Doğru +use Filament\Schemas\Components\Tabs; // ✅ Doğru +use Filament\Schemas\Components\Fieldset; // ✅ Doğru +``` + +#### **YANLIŞ KULLANIM (Eski Filament 3.x):** +```php +// ❌ YANLIŞ - Bu namespace'ler Filament 4'te YOK! +use Filament\Tables\Actions\EditAction; // ❌ +use Filament\Forms\Components\Section; // ❌ +use Filament\Forms\Components\Grid; // ❌ + +// ❌ YANLIŞ - Eski metod adları +$table + ->actions([...]) // ❌ Kullanma! + ->bulkActions([...]) // ❌ Kullanma! +``` + +#### **ÖZET:** +- ✅ **Table Actions:** `Filament\Actions\` namespace +- ✅ **Table Columns:** `Filament\Tables\Columns\` namespace +- ✅ **Table Filters:** `Filament\Tables\Filters\` namespace +- ✅ **Form Inputs:** `Filament\Forms\Components\` namespace +- ✅ **Layout Components:** `Filament\Schemas\Components\` namespace (Section, Grid, Tabs) +- ✅ **Table Methods:** `->recordActions()` ve `->toolbarActions()` + ### Dil Dosyası Yapısı ```php setTranslation('field_name', 'en', 'Translation', 'published'); + +// Çeviri oku +$model->translate('field_name'); // Mevcut dilde +$model->translate('field_name', 'en'); // Belirli dilde +$model->translate('field_name', 'en', false); // Fallback olmadan + +// Çeviri kontrolü +$model->hasTranslation('field_name', 'en'); + +// İlerleme takibi +$model->getTranslationProgress(); // ['tr' => 100, 'en' => 75] +$model->getMissingTranslations('en'); // ['meta_description'] +``` + +### Translation Workflow +- `draft` → `review` → `approved` → `published` +- Sadece `published` çeviriler son kullanıcıya görünür +- User-language permissions ile kontrol edilir + +### Helper Functions +```php +current_language(); // Mevcut dil objesi +available_languages(); // Aktif diller +translate_model($model, 'field', 'en'); // Model çevirisi +user_can_manage_language('en'); // Kullanıcı yetkisi +switch_language('en'); // Dil değiştir +``` + +### Dokümantasyon +- `docs/TRANSLATION_SYSTEM.md` - Tam sistem dokümantasyonu +- `docs/TRANSLATION_QUICK_START.md` - Hızlı başlangıç rehberi