mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Companies\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
|
use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
|
use App\Http\Resources\ContactResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class UpdateCompanyContactNumberLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Updated Company Contact Number',
|
|
'message' => 'You have successfully updated the Company Contact Number'
|
|
];
|
|
}
|
|
|
|
/** @var FetchesContact */
|
|
private $fetchesContact;
|
|
|
|
/** @var UpdatesContact */
|
|
private $updatesContact;
|
|
|
|
/**
|
|
* UpdateCompanyControllersLogic constructor.
|
|
* @param FetchesContact $fetchesContact
|
|
* @param UpdatesContact $updatesContact
|
|
*/
|
|
public function __construct(FetchesContact $fetchesContact, UpdatesContact $updatesContact)
|
|
{
|
|
$this->fetchesContact = $fetchesContact;
|
|
$this->updatesContact = $updatesContact;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$query = $this->fetchesContact->execute(['id' => $request->input('id')]);
|
|
|
|
$contact = new ContactObject(
|
|
$query->reference,
|
|
$request->input('contactNumber'),
|
|
$query->email,
|
|
$query->wechat_id
|
|
);
|
|
|
|
$this->updatesContact->execute($query, $contact);
|
|
|
|
return $this->resourceResponse(new ContactResource($query));
|
|
|
|
}
|
|
|
|
}
|