<?php

namespace Modules\Patient\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Http\Request;
use Modules\Patient\DTO\PatientSettingFilter;
use Modules\Patient\Models\Patient;
use Modules\Patient\Services\PatientService;
use Modules\Patient\Transformers\PatientResource;

class PatientController extends Controller
{
    use AuthorizesRequests;

    protected $patientService;

    public function __construct(PatientService $patientService)
    {
        $this->patientService = $patientService;
    }

    /**
     * Display a listing of the resource.
     */
    public function index(Request $request)
    {
        $this->authorize('viewAny', Patient::class);
        $filters = PatientSettingFilter::fromRequest($request);

        return (PatientResource::collection($this->patientService->list($filters)))->additional([
            'status' => true,
            'message' => 'Patients retrieved successfully.'
        ]);
    }


    /**
     * Show the form for creating a new resource.
     */
    public function create()
    {
        return view('patient::create');
    }

    /**
     * Store a newly created resource in storage.
     */
    public function store(Request $request) {}

    /**
     * Show the specified resource.
     */
    public function show($id)
    {
        return view('patient::show');
    }

    /**
     * Show the form for editing the specified resource.
     */
    public function edit($id)
    {
        return view('patient::edit');
    }

    /**
     * Update the specified resource in storage.
     */
    public function update(Request $request, $id) {}

    /**
     * Remove the specified resource from storage.
     */
    public function destroy($id) {}
}
