<?php

namespace App\Http\Controllers\Announcement;//call to announcement controller folder
use App\Http\Controllers\Controller;//call to controller class
use Carbon\Carbon;//call to carbon to return the current time with a Carbon instance

use App\Models\Announcement;
use Illuminate\Http\Request;

class ViewAnnouncementsController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //returns the page for this route
        $announcements = Announcement::whereDate('start_date', '<=', Carbon::now())
            ->whereDate('end_date', '>=', Carbon::now())
            ->get();
        return view('announcement.view_announcements', compact('announcements'));
    }

}
