<?php

namespace App\Http\Controllers\Public;

use App\Http\Controllers\Controller;
use App\Models\Department;
use App\Models\JobPosting;

class DepartmentController extends Controller
{
    public function show(string $slug)
    {
        $department = Department::where('slug', $slug)
            ->where('is_active', true)
            ->firstOrFail();

        $jobs = JobPosting::published()
            ->where('department', $department->name)
            ->orderByDesc('is_featured')
            ->latest('published_at')
            ->get();

        // Diğer aktif departmanlar (sidebar için)
        $otherDepartments = Department::active()
            ->where('id', '!=', $department->id)
            ->orderBy('sort_order')
            ->get();

        return view('public.department', compact('department', 'jobs', 'otherDepartments'));
    }
}