Skip to content

Instantly share code, notes, and snippets.

@mansha99
Last active August 19, 2023 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mansha99/332599022398b87739eb49d80d812b52 to your computer and use it in GitHub Desktop.
Save mansha99/332599022398b87739eb49d80d812b52 to your computer and use it in GitHub Desktop.
<?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