diff --git a/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php b/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php index 15347c5..792a6b5 100644 --- a/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php +++ b/app/Filament/Admin/Resources/Blogs/Schemas/BlogForm.php @@ -6,6 +6,7 @@ use App\Filament\Admin\Resources\Components\TranslationTabs; use Filament\Forms\Components\Checkbox; use Filament\Forms\Components\DateTimePicker; use Filament\Forms\Components\FileUpload; +use Filament\Forms\Components\Placeholder; use Filament\Forms\Components\RichEditor; use Filament\Schemas\Components\Section; use Filament\Forms\Components\Select; @@ -80,11 +81,17 @@ class BlogForm ->helperText(__('blog.featured_image_helper')) ->columnSpanFull(), + Placeholder::make('intern_author_info') + ->label('Stajyer Yazarı') + ->content(fn ($record) => $record?->careerApplication?->name ?? '-') + ->visible(fn ($record) => $record?->career_application_id !== null) + ->columnSpanFull(), + Select::make('author_id') ->label(__('blog.author_field')) ->relationship('author', 'name') - ->default(auth()->id()) - ->required() + ->nullable() + ->placeholder('Boş bırakılırsa stajyer yazarı veya Trunçgil') ->columnSpanFull(), Select::make('category_id') @@ -110,7 +117,9 @@ class BlogForm ->label(__('blog.status_field')) ->options([ 'draft' => __('blog.status_draft'), + 'pending' => __('blog.status_pending'), 'published' => __('blog.status_published'), + 'rejected' => __('blog.status_rejected'), 'archived' => __('blog.status_archived'), ]) ->default('draft') diff --git a/app/Filament/Admin/Resources/Blogs/Tables/BlogsTable.php b/app/Filament/Admin/Resources/Blogs/Tables/BlogsTable.php index 2ac371d..3b4611a 100644 --- a/app/Filament/Admin/Resources/Blogs/Tables/BlogsTable.php +++ b/app/Filament/Admin/Resources/Blogs/Tables/BlogsTable.php @@ -76,7 +76,13 @@ class BlogsTable TextColumn::make('author.name') ->label(__('blog.table_author')) - ->searchable() + ->formatStateUsing(fn ($state, $record) => $record->author_name) + ->searchable(query: function ($query, string $search) { + $query->where(function ($q) use ($search) { + $q->whereHas('author', fn ($sub) => $sub->where('name', 'like', "%{$search}%")) + ->orWhereHas('careerApplication', fn ($sub) => $sub->where('name', 'like', "%{$search}%")); + }); + }) ->sortable(), TextColumn::make('category.name') diff --git a/app/Http/Controllers/BlogController.php b/app/Http/Controllers/BlogController.php index a8c3431..dfa1f19 100644 --- a/app/Http/Controllers/BlogController.php +++ b/app/Http/Controllers/BlogController.php @@ -20,7 +20,7 @@ class BlogController extends Controller $settings = class_exists(Setting::class) ? (Setting::query()->first()) : null; $query = class_exists(Blog::class) - ? Blog::with(['category', 'author']) + ? Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() : null; @@ -29,6 +29,9 @@ class BlogController extends Controller if ($query && $request->has('author') && $request->author) { $query = $query->where('author_id', $request->author); } + if ($query && $request->has('intern') && $request->intern) { + $query = $query->where('career_application_id', $request->intern); + } // Category filtresi if ($query && $request->has('category') && $request->category) { @@ -130,14 +133,14 @@ class BlogController extends Controller if (!$request->ajax()) { if (class_exists(Blog::class)) { // Karusel: Öne çıkarılan ya da en güncel 5 yazı - $carouselPosts = Blog::with(['category', 'author']) + $carouselPosts = Blog::with(['category', 'author', 'careerApplication']) ->published() ->featured() ->latest('published_at') ->take(5) ->get(); if ($carouselPosts->isEmpty()) { - $carouselPosts = Blog::with(['category', 'author']) + $carouselPosts = Blog::with(['category', 'author', 'careerApplication']) ->published() ->latest('published_at') ->take(5) @@ -145,7 +148,7 @@ class BlogController extends Controller } // Popüler Yazılar: En çok okunan 3 yazı - $popularPosts = Blog::with(['category', 'author']) + $popularPosts = Blog::with(['category', 'author', 'careerApplication']) ->published() ->orderBy('view_count', 'desc') ->take(3) @@ -224,14 +227,14 @@ class BlogController extends Controller if (!class_exists(Blog::class)) { abort(404); } - $post = Blog::with(['category', 'author']) + $post = Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() ->where('slug', $slug) ->firstOrFail(); // İlgili blog gönderilerini al (aynı kategoriden, mevcut gönderi hariç) - $relatedPosts = Blog::with(['category', 'author']) + $relatedPosts = Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() ->where('id', '!=', $post->id) @@ -244,7 +247,7 @@ class BlogController extends Controller // Eğer aynı kategoriden yeterli gönderi yoksa, diğer kategorilerden ekle if ($relatedPosts->count() < 4) { - $additionalPosts = Blog::with(['category', 'author']) + $additionalPosts = Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() ->where('id', '!=', $post->id) diff --git a/app/Models/Blog.php b/app/Models/Blog.php index babd592..b335a2c 100644 --- a/app/Models/Blog.php +++ b/app/Models/Blog.php @@ -82,6 +82,36 @@ class Blog extends Model return '/blog/' . $this->slug; } + public function getAuthorNameAttribute() + { + if ($this->author) { + return $this->author->name; + } + if ($this->careerApplication) { + return $this->careerApplication->name; + } + return __('blog.default_author'); + } + + public function getAuthorRoleAttribute() + { + if ($this->author && $this->author->role) { + return $this->author->role; + } + if ($this->careerApplication) { + return 'Stajyer Yazılım Geliştirici'; + } + return 'Trunçgil Teknoloji Editörü'; + } + + public function getAuthorAvatarUrlAttribute() + { + if ($this->author && $this->author->avatar) { + return asset('storage/' . $this->author->avatar); + } + return asset('assets/img/avatars/u5.webp'); + } + public function getFeaturedImageUrlAttribute() { if ($this->featured_image) { diff --git a/app/Support/BlogStructuredData.php b/app/Support/BlogStructuredData.php index 2f7e381..f59bac9 100644 --- a/app/Support/BlogStructuredData.php +++ b/app/Support/BlogStructuredData.php @@ -61,7 +61,7 @@ class BlogStructuredData extends StructuredData 'inLanguage' => app()->getLocale(), 'author' => [ '@type' => 'Person', - 'name' => $post->author->name ?? __('blog.default_author'), + 'name' => $post->author_name, ], 'publisher' => self::publisherNode(), 'datePublished' => $publishedAt->toIso8601String(), diff --git a/lang/en/blog.php b/lang/en/blog.php index 2b01912..c573a8e 100644 --- a/lang/en/blog.php +++ b/lang/en/blog.php @@ -61,7 +61,9 @@ return [ // Status options 'status_draft' => 'Draft', + 'status_pending' => 'Pending Approval', 'status_published' => 'Published', + 'status_rejected' => 'Revision Requested', 'status_archived' => 'Archived', // Messages diff --git a/lang/tr/blog.php b/lang/tr/blog.php index ede6dc8..1a10942 100644 --- a/lang/tr/blog.php +++ b/lang/tr/blog.php @@ -61,7 +61,9 @@ return [ // Status options 'status_draft' => 'Taslak', + 'status_pending' => 'Onay Bekliyor', 'status_published' => 'Yayınlandı', + 'status_rejected' => 'Revize İstendi', 'status_archived' => 'Arşivlendi', // Messages diff --git a/resources/views/blog/index.blade.php b/resources/views/blog/index.blade.php index 0621e31..d7f0891 100644 --- a/resources/views/blog/index.blade.php +++ b/resources/views/blog/index.blade.php @@ -37,11 +37,11 @@ {{ $cDate }} - @if($cPost->author) + @if($cPost->author || $cPost->careerApplication)
Trunçgil Teknoloji editörleri tarafından kaleme alınmış bu makalede teknoloji, yazılım geliştirme ve dijital dönüşüm konularına dair güncel gelişmeleri incelediniz. Destek ve sorularınız için bizimle iletişime geçebilirsiniz.
@@ -181,9 +181,9 @@ $publishedDate = $post->published_at ? $post->published_at->toIso8601String() : $post->created_at->toIso8601String(); $modifiedDate = $post->updated_at ? $post->updated_at->toIso8601String() : $publishedDate; - $authorName = $post->author ? $post->author->name : 'Trunçgil'; - $authorRole = $post->author && $post->author->role ? $post->author->role : 'Trunçgil Teknoloji Editörü'; - $authorUrl = route('blog.index', ['author' => $post->author_id ?? 1]); + $authorName = $post->author_name; + $authorRole = $post->author_role; + $authorUrl = $post->author_id ? route('blog.index', ['author' => $post->author_id]) : ($post->career_application_id ? route('blog.index', ['intern' => $post->career_application_id]) : route('blog.index')); $siteName = setting('site_name', 'Trunçgil Teknoloji'); $siteLogo = setting('site_logo') ? (str_starts_with(setting('site_logo'), 'http') ? setting('site_logo') : asset('storage/' . ltrim(setting('site_logo'), '/'))) : asset('assets/img/logo.png'); diff --git a/resources/views/components/custom/blog.blade.php b/resources/views/components/custom/blog.blade.php index cb9674c..9c4f1d5 100644 --- a/resources/views/components/custom/blog.blade.php +++ b/resources/views/components/custom/blog.blade.php @@ -1,6 +1,6 @@ @php // Blog modelinden published içerikleri çek - $blogs = \App\Models\Blog::with(['category', 'author']) + $blogs = \App\Models\Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() ->latest('published_at')