update addon HRM
Some checks failed
Build, Push and Deploy / build-and-push (push) Failing after 3m30s
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 15s
Build, Push and Deploy / deploy-staging (push) Has been skipped
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-05-04 23:04:09 +07:00
parent 7be161f4e4
commit 3e1b64e008
131 changed files with 8281 additions and 290 deletions

View File

@@ -0,0 +1,49 @@
<?php
namespace App\Traits;
trait ImageUrlTrait
{
/**
* Automatically prepend the base URL to image fields.
*
* @param string $key
* @return mixed
*/
public function getAttribute($key)
{
$value = parent::getAttribute($key);
// Check if the current key is in the imageFields array
if (isset($this->imageFields) && in_array($key, $this->imageFields) && $value) {
// Check if it's already a full URL
if (!filter_var($value, FILTER_VALIDATE_URL)) {
return asset($value);
}
}
return $value;
}
/**
* Handle serialization to array.
*
* @return array
*/
public function attributesToArray()
{
$attributes = parent::attributesToArray();
if (isset($this->imageFields)) {
foreach ($this->imageFields as $field) {
if (isset($attributes[$field]) && $attributes[$field]) {
if (!filter_var($attributes[$field], FILTER_VALIDATE_URL)) {
$attributes[$field] = asset($attributes[$field]);
}
}
}
}
return $attributes;
}
}