diff --git a/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php b/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php index 792a6b5..832433c 100644 --- a/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php +++ b/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php @@ -146,12 +146,20 @@ class BlogForm TextInput::make('meta_title') ->label(__('blog.meta_title_field')) ->maxLength(60) + ->extraInputAttributes(['maxlength' => 60]) + ->live(debounce: 200) + ->hint(fn ($state) => mb_strlen((string) $state) . ' / 60') + ->hintColor(fn ($state) => mb_strlen((string) $state) > 60 ? 'danger' : 'gray') ->helperText(__('blog.meta_title_helper')), Textarea::make('meta_description') ->label(__('blog.meta_description_field')) ->rows(3) ->maxLength(160) + ->extraInputAttributes(['maxlength' => 160]) + ->live(debounce: 200) + ->hint(fn ($state) => mb_strlen((string) $state) . ' / 160') + ->hintColor(fn ($state) => mb_strlen((string) $state) > 160 ? 'danger' : 'gray') ->helperText(__('blog.meta_description_helper')) ->columnSpanFull(), ]) diff --git a/app/Filament/Admin/Resources/Pages/Schemas/Sections/SeoSection.php b/app/Filament/Admin/Resources/Pages/Schemas/Sections/SeoSection.php index 62123dd..d5c308a 100644 --- a/app/Filament/Admin/Resources/Pages/Schemas/Sections/SeoSection.php +++ b/app/Filament/Admin/Resources/Pages/Schemas/Sections/SeoSection.php @@ -15,12 +15,20 @@ class SeoSection TextInput::make('meta_title') ->label(__('pages.meta_title_field')) ->maxLength(60) + ->extraInputAttributes(['maxlength' => 60]) + ->live(debounce: 200) + ->hint(fn ($state) => mb_strlen((string) $state) . ' / 60') + ->hintColor(fn ($state) => mb_strlen((string) $state) > 60 ? 'danger' : 'gray') ->helperText(__('pages.meta_title_helper_text')), Textarea::make('meta_description') ->label(__('pages.meta_description_field')) ->rows(3) ->maxLength(160) + ->extraInputAttributes(['maxlength' => 160]) + ->live(debounce: 200) + ->hint(fn ($state) => mb_strlen((string) $state) . ' / 160') + ->hintColor(fn ($state) => mb_strlen((string) $state) > 160 ? 'danger' : 'gray') ->helperText(__('pages.meta_description_helper_text')) ->columnSpanFull(), ]) diff --git a/app/Http/Controllers/CareerController.php b/app/Http/Controllers/CareerController.php index 8ac9569..2bc5639 100644 --- a/app/Http/Controllers/CareerController.php +++ b/app/Http/Controllers/CareerController.php @@ -156,6 +156,8 @@ class CareerController extends Controller 'title' => 'required|string|max:255', 'intern_category' => 'required|string|in:experience,technical_challenge,product_showcase', 'excerpt' => 'nullable|string|max:500', + 'meta_title' => 'nullable|string|max:60', + 'meta_description' => 'nullable|string|max:160', 'content' => 'required|string|min:50', 'featured_image' => 'nullable|image|mimes:jpeg,png,jpg,webp|max:5120', 'action_type' => 'required|string|in:draft,submit', @@ -164,6 +166,8 @@ class CareerController extends Controller 'intern_category.required' => 'Lütfen bir kategori seçin.', 'content.required' => 'Lütfen blog yazısı içeriğini girin.', 'content.min' => 'Blog içeriği en az 50 karakter olmalıdır.', + 'meta_title.max' => 'Meta Başlık en fazla 60 karakter olmalıdır.', + 'meta_description.max' => 'Meta Açıklama en fazla 160 karakter olmalıdır.', 'featured_image.image' => 'Görsel geçerli bir resim dosyası olmalıdır.', ]); @@ -195,8 +199,8 @@ class CareerController extends Controller $blog->excerpt = $request->excerpt; $blog->content = $request->content; $blog->status = $status; - $blog->meta_title = $request->title; - $blog->meta_description = Str::limit(strip_tags($request->excerpt ?: $request->content), 160); + $blog->meta_title = $request->filled('meta_title') ? Str::limit($request->meta_title, 60, '') : Str::limit($request->title, 60, ''); + $blog->meta_description = $request->filled('meta_description') ? Str::limit($request->meta_description, 160, '') : Str::limit(strip_tags($request->excerpt ?: $request->content), 160, ''); if ($request->hasFile('featured_image')) { if ($blog->featured_image && Storage::disk('public')->exists($blog->featured_image)) { diff --git a/app/Models/Blog.php b/app/Models/Blog.php index b335a2c..be12c4f 100644 --- a/app/Models/Blog.php +++ b/app/Models/Blog.php @@ -109,7 +109,7 @@ class Blog extends Model if ($this->author && $this->author->avatar) { return asset('storage/' . $this->author->avatar); } - return asset('assets/img/avatars/u5.webp'); + return asset('assets/img/avatars/avatar-default.svg'); } public function getFeaturedImageUrlAttribute() diff --git a/app/Traits/HasTranslations.php b/app/Traits/HasTranslations.php index 5caca95..5fd0768 100644 --- a/app/Traits/HasTranslations.php +++ b/app/Traits/HasTranslations.php @@ -45,14 +45,14 @@ trait HasTranslations // 1. Try translations table $translation = $this->getTranslation($fieldName, $languageCode); - if ($translation && !empty($translation->field_value)) { + if ($translation && $this->hasValidTranslationContent($translation->field_value)) { return $translation->field_value; } // 2. Fallback to default language from translations table if ($fallback && $languageCode !== $this->getDefaultLanguageCode()) { $defaultTranslation = $this->getTranslation($fieldName, $this->getDefaultLanguageCode()); - if ($defaultTranslation && !empty($defaultTranslation->field_value)) { + if ($defaultTranslation && $this->hasValidTranslationContent($defaultTranslation->field_value)) { return $defaultTranslation->field_value; } } @@ -267,6 +267,23 @@ trait HasTranslations } } + /** + * Check if translation content has meaningful text or media + */ + protected function hasValidTranslationContent(mixed $value): bool + { + if (empty($value)) { + return false; + } + + if (is_string($value)) { + $stripped = trim(strip_tags($value, '