<?php

namespace App\Http\Controllers\StudentPortal;

use App\Http\Controllers\Controller;
use App\Http\Controllers\StudentPortal\Concerns\ResolvesStudent;
use App\Models\Notice;
use Illuminate\View\View;

class NoticeController extends Controller
{
    use ResolvesStudent;

    public function index(): View
    {
        $student = $this->student();

        $notices = Notice::where('branch_id', $student->branch_id)
            ->published()->forAudience('students')
            ->latest('published_at')->latest('id')->paginate(15);

        return view('student.notices', compact('notices'));
    }
}
