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