Last active
August 19, 2023 10:54
-
-
Save mansha99/332599022398b87739eb49d80d812b52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Services; | |
use App\DTO\AddressChangeDTO; | |
use App\Models\Order; | |
use App\Respository\OrderRepository; | |
use Exception; | |
class OrderService | |
{ | |
private $orderRepository; | |
private $addressChangeService; | |
public function __construct(OrderRepository $orderRepository, AddressChangeNotifService $addressChangeService) | |
{ | |
$this->orderRepository = $orderRepository; | |
$this->addressChangeService = $addressChangeService; | |
} | |
public function updateAddressForOrder($id, AddressChangeDTO $data) | |
{ | |
try { | |
//should be | |
//$order = Order::find($id); | |
//just for demo | |
$order = new Order(); | |
//Do actual update using repo | |
//--- | |
$this->addressChangeService->sendNotification($order); | |
return ['message' => "Record Updated", 'status' => 'SUCCESS']; | |
} catch (Exception $ee) { | |
return ['message' => $ee->getMessage(), 'status' => 'FAULIRE']; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment