'array', 'cash' => 'boolean' ]; protected static $logName = 'regions'; protected static $logOnlyDirty = true; protected static $logAttributes = ['name', 'cash']; protected static $submitEmptyLogs = false; /** * @return \Illuminate\Database\Eloquent\Relations\HasMany */ public function cities() { return $this->hasMany(City::class, 'region_id', 'id'); } public function getName(): string { return (string) $this->name[App::getLocale()] ?? null; } public function deliveryPrice() { return $this->hasMany(DeliveryPrice::class, 'region_id', 'id'); } public function getDeliveryPrice($powerId): ?float { $deliveryPrice = collect($this->deliveryPrice)->where('power_id', $powerId)->first(); return $deliveryPrice ? $deliveryPrice['price'] : null; } }