HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1014-azure #14~24.04.1-Ubuntu SMP Fri Oct 3 20:52:11 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/app/AppointmentReason.php
<?php

namespace App;

use Config;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Storage;

class AppointmentReason extends Model
{
    protected $appends = ['reason_documents', 'reason_documents_str'];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    public function getReasonDocumentsStrAttribute()
    {
        $variableLibrary = new \App\Library\VariableLibrary;
        $value = $this->reasons_document;
        if ($value != null) {
            $decodeData = json_decode($value);
            /** @var array|null $decodeData */
            if (count($decodeData)) {
                $arr = $decodeData;

                return $arr;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }

    public function getReasonDocumentsAttribute()
    {
        $variableLibrary = new \App\Library\VariableLibrary;
        $value = $this->reasons_document;
        /** @var string $value */
        if ($value != null) {
            $decodeData = json_decode($value);
            /** @var array|null $decodeData */
            if (count($decodeData) != 0) {
                $arr = $decodeData;
                /** @var array $arr */
                $out = [];
                for ($i = 0; $i < count($arr); $i++) {
                    if (Config::get('filesystems.default') == 's3') {
                        $json = Storage::temporaryUrl('digimed/images/appointment/'.$arr[$i], now()->addMinutes(30));
                    } else {
                        $json = Storage::disk('public')->url('digimed/images/appointment/'.$arr[$i]);
                    }

                    array_push($out, $json);
                }

                return $out;
            } else {
                return null;
            }
        } else {
            return null;
        }
    }
}