HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/app/Library/ActivityLibrary.php
<?php
namespace App\Library;

use Spatie\Activitylog\Models\Activity;
use DB;

class ActivityLibrary {

	public function labelGet() {
		return [
			'vaccinationGet.name' => 'vaccination',
			'alcoholConsumptionGet.name' => 'alcohol consumption',
			'allergieGet.name' => 'allergie',
			'dietaryRestrictionGet.name' => 'dietary restriction',
			'medicalConditionGet.name' => 'medical condition',
			'medicationGet.name' => 'medication',
			'procedureGet.name' => 'procedure',
			'recreationalDrugGet.name' => 'recreational drug',
			'tobaccoUseGet.name' => 'tobacco use',
            'prosthesisGet.name' => 'prosthesis',
		];
	}

	public function propertyMsgRetrieve($properties, $action, $subject) {
		$attributes = $properties['attributes'];
		$arr = [];
		foreach ($attributes as $key => $value) {
			$nameAlternate = str_replace("_"," ",$key);
			$labelResult = $this->labelGet();
			if (array_key_exists($key, $labelResult)) {
			    $name = $labelResult[$key];
			} else {
				$name = $nameAlternate;
			}
			if($action == "created") {
				if($subject == "App\HealthProfileProsthesis"){
					$label = $name ." ".$value." Changed to YES";
				}
				else
					$label = __('activity_log.created.value', [ 'name' => $name, 'value' => $value ]);
			} else {
				$old = $properties['old'];
				$label = __('activity_log.updated.value', [ 'name' => $name, 'old' => $old[$key], 'new' => $value ]);
			}
			array_push($arr, $label);
		}
		return $arr;
	}
}