<?php

namespace App\Classes\Modules\AddressBook\Services;


use App\Http\Resources\AddressBook as AddressBookResource;
use App\Models\Company;

class ListsAddressBook
{
    /** @var  Company */
    private $repository;

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


    public function execute(String $companyId){

        $addresses = $this->repository->findOrfail($companyId)->addressBook()->orderBy('created_at')->paginate(5);
        return AddressBookResource::collection($addresses);
    }
}