<?php


namespace App\Models\OrderManagement\Observers;


use App\Models\OrderManagement\BillingDesk;

class PointOfSaleObserver {

    public function created(BillingDesk $pointOfSale){
        $attributes = $pointOfSale->getAttributes();

        $period = $attributes['period'] ?? getSettingsOf("current_orders_period") ?? null;
        if (!isset($attributes['status_code'])){
            $order->setAttribute("status_code",Status::UNPROCESSED);
        }
        if (blank($period)){
            $order->setAttribute("period",date('Y-m'));
        }
        if (!isset($attributes['ref_id'])){
            $order->setAttribute("ref_id",Order::newId());
        }
        return $order;
    }

}
