mirror of
https://gitlab.com/omair-personal/izyim.git
synced 2026-08-19 20:34:09 +00:00
8a28eb1790
This reverts merge request !5
44 lines
939 B
PHP
44 lines
939 B
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Contacts\Services;
|
|
|
|
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Models\Contact;
|
|
|
|
class UpdateContact
|
|
{
|
|
/** @var Contact */
|
|
private $repository;
|
|
|
|
/**
|
|
* UpdateContact constructor.
|
|
* @param Contact $repository
|
|
*/
|
|
public function __construct(Contact $repository)
|
|
{
|
|
$this->repository = $repository;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param int $id
|
|
* @param ContactObject $object
|
|
* @return Contact
|
|
*/
|
|
public function execute(int $id, ContactObject $object)
|
|
{
|
|
/** @var Contact $contact */
|
|
$contact = $this->repository->findOrFail($id);
|
|
$contact ->name = $object->getName();
|
|
$contact ->designation = $object->getDesignation();
|
|
$contact ->contact = $object->getContact();
|
|
$contact ->email = $object->getEmail();
|
|
|
|
$contact->save();
|
|
|
|
return $contact;
|
|
|
|
}
|
|
|
|
} |