Skip to content

Commit

Permalink
Merge pull request #41 from bdsumon4u/dev
Browse files Browse the repository at this point in the history
Temp: Set Pathao Location From Location ID
  • Loading branch information
bdsumon4u authored Apr 24, 2024
2 parents cd6ff0f + 9e2d9a4 commit 5da07b0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ class Order extends Model

public static function booted()
{
static::retrieved(function (Order $order) {
if (empty($order->data['city_name'] ?? '') && !empty($order->data['city_id'] ?? '')) {
$order->fill(['data' => ['city_name' => current(array_filter($order->getCityList(), fn ($c) => $c->city_id == $order->data['city_id']))->city_name ?? 'N/A']]);
$order->fill(['data' => ['area_name' => current(array_filter($order->getAreaList(), fn ($a) => $a->zone_id == $order->data['area_id']))->zone_name ?? 'N/A']]);
$order->save();
}
});

static::saving(function (Order $order) {
if (! $order->isDirty('data')) return;

Expand Down

0 comments on commit 5da07b0

Please sign in to comment.