<?php

namespace App\Classes\Modules\Companies\Services;


use App\Classes\ValueObjects\Constants\SegmentConstants;
use App\Models\Company;

class FetchesCompanyPaymentAttemptLimit
{

    /**
     * @param Company $company
     * @return mixed
     */
    public function execute(Company $company){
        return $company->segments()->with([
            'constants' => function ($query) {
                $query->where('reference', SegmentConstants::PAYMENT_ATTEMPT_DURATION_LIMIT);
            }])->get()->pluck('constants')->flatten()->pluck('detail')->max('minutes');
    }

}