@extends('layouts.app')

@section('title', 'Announcements')

@section('content')
    <h1 class="text-2xl font-bold mb-6">Announcements</h1>
    <div class="space-y-4">
        @foreach($announcements as $announcement)
            <div class="border rounded-lg p-4 shadow">
                <h3 class="text-xl font-semibold">{{ $announcement->title }}</h3>
                <p class="text-sm text-gray-500">Posted by {{ $announcement->postedBy->name ?? 'Admin' }} on {{ $announcement->created_at->format('M d, Y') }}</p>
                <p class="mt-2">{{ $announcement->content }}</p>
                @if($announcement->image)
                    <img src="{{ asset('storage/' . $announcement->image) }}" alt="{{ $announcement->title }}" class="w-full h-48 object-cover rounded mt-2">
                @endif
            </div>
        @endforeach
    </div>
    <div class="mt-6">
        {{ $announcements->links() }}
    </div>
@endsection