mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
e7c0e17ee4
# Conflicts: # app/Classes/Modules/Segments/ControllersLogic/UpdateConstantPostcodeLogic.php # app/Classes/ValueObjects/Constants/TransactionType.php # routes/api.php # routes/web.php
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Contacts\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Contacts\Services\UpdatesContact;
|
|
use App\Classes\Modules\Contacts\DataTransferObjects\ContactObject;
|
|
use App\Classes\Modules\Contacts\Services\FetchesContact;
|
|
use App\Http\Resources\ContactResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class UpdateContactLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Updated Contact',
|
|
'message' => 'You have successfully updated the Contact'
|
|
];
|
|
}
|
|
|
|
/** @var UpdatesContact */
|
|
private $updatesContact;
|
|
|
|
/** @var FetchesContact */
|
|
private $fetchesContact;
|
|
|
|
/**
|
|
* UpdateContactLogic constructor.
|
|
* @param UpdatesContact $updatesContact
|
|
* @param FetchesContact $fetchesContact
|
|
*/
|
|
public function __construct(UpdatesContact $updatesContact, FetchesContact $fetchesContact)
|
|
{
|
|
$this->updatesContact = $updatesContact;
|
|
$this->fetchesContact = $fetchesContact;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$object = new ContactObject(
|
|
$request->input('reference'),
|
|
$request->input('phone'),
|
|
$request->input('email'),
|
|
$request->input('wechat_id')
|
|
);
|
|
|
|
// $this->canUpdateContact->passes($object);
|
|
|
|
$query = $this->fetchesContact->execute(['id' => $request->route('id')]);
|
|
|
|
$query = $this->updatesContact->execute($query, $object);
|
|
|
|
return $this->resourceResponse(new ContactResource($query));
|
|
}
|
|
|
|
} |