<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Auth;
// app includes
use App\Http\Utils\PestroutesUtils;

class ReportController extends Controller
{

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function appointments(Request $request)
    {

        $pestroutes = new PestroutesUtils();
        $appointments = $pestroutes->getAppointments();
        //        dd($appointments);
        if ($request->exportPDF) {
            $data = [
                'appointments' => $appointments
            ];

            $pdf = \PDF::loadView('reports.appointmentDataPDF', $data);

            return $pdf->download('report.pdf');
        } else {
            return view('reports.appointments', compact('appointments'));
        }
    }
}
