From b9a069b9054d7d3c869a196752acf6b556bcd903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Cmit=20Tun=C3=A7?= Date: Tue, 1 Sep 2026 14:58:42 +0300 Subject: [PATCH] feat(blog): blog yazilari tarihe gore sondan basa (DESC) siralandi --- app/Http/Controllers/BlogController.php | 2 +- app/Models/CareerApplication.php | 2 +- resources/views/components/custom/blog.blade.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/BlogController.php b/app/Http/Controllers/BlogController.php index dfa1f19..974d93d 100644 --- a/app/Http/Controllers/BlogController.php +++ b/app/Http/Controllers/BlogController.php @@ -56,7 +56,7 @@ class BlogController extends Controller } $posts = $query - ? $query->latest('published_at')->paginate(12) + ? $query->orderByRaw('COALESCE(published_at, created_at) DESC')->paginate(12) : collect(); // Blog sayfa ayarlarını bul (varsa) diff --git a/app/Models/CareerApplication.php b/app/Models/CareerApplication.php index 8f00a65..d8606cc 100644 --- a/app/Models/CareerApplication.php +++ b/app/Models/CareerApplication.php @@ -53,7 +53,7 @@ class CareerApplication extends Model */ public function blogs() { - return $this->hasMany(Blog::class, 'career_application_id'); + return $this->hasMany(Blog::class, 'career_application_id')->orderBy('created_at', 'desc'); } protected static function booted() diff --git a/resources/views/components/custom/blog.blade.php b/resources/views/components/custom/blog.blade.php index 9c4f1d5..ef91923 100644 --- a/resources/views/components/custom/blog.blade.php +++ b/resources/views/components/custom/blog.blade.php @@ -3,7 +3,7 @@ $blogs = \App\Models\Blog::with(['category', 'author', 'careerApplication']) ->withCount('comments') ->published() - ->latest('published_at') + ->orderByRaw('COALESCE(published_at, created_at) DESC') ->limit(6) ->get(); @endphp