<?php

namespace App\Classes\Modules\Companies\Services;

use App\Classes\General\Services\GeneratesInitials;
use App\Classes\Modules\Companies\DataTransferObjects\ConnectionObject;
use App\Classes\ValueObjects\Constants\ConnectionStatus;

class CreatesCompanyConnection
{

    public function execute(ConnectionObject $connection){
        $connection->getInviter()->connections()->attach($connection->getInvitee(),
            [
                'marking' => mt_rand(100, 999).(new GeneratesInitials())->name($connection->getInviter()->company->name)->length(3)->generate(),
                'status' => ConnectionStatus::APPROVED,
                'instigator' => $connection->getInvitee()->id
            ]
        );
    }

}