<?php

namespace App\Classes\Modules\Contacts\Services;


use App\Models\Contact;
use App\Http\Resources\Contact as ContactResource;

class DeletesContact
{
    /** @var  Contact */
    private $repository;

    /**
     * DeletesContact constructor.
     * @param Contact $repository
     */
    public function __construct(Contact $repository)
    {
        $this->repository = $repository;
    }


    public function execute(String $id){

        $contact = $this->repository->findOrFail($id);

        if($contact->delete()){

            // Return single address as a resource
            return new ContactResource($contact);

        }
    }

}