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/LabCategory.php
<?php

namespace App;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Storage;
use Config;

class LabCategory extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = ['name', 'lab_id', 'description', 'image'];
    protected $appends = ['image_url'];

    public function lab()
    {
        return $this->belongsTo(Lab::class);
    }

    public function getImageUrlAttribute()
    {
        $value = $this->image;
        if ($value) {
            if (Config::get('filesystems.default') == 's3') {
                $url = Storage::temporaryUrl(
                    'digimed/images/lab-category/' . $this->lab_id . '/' . $value,
                    now()->addMinutes(30)
                );
            } else {
                $url = Storage::url('digimed/images/lab-category/' . $this->lab_id . '/' . $value);
            }

            return $url;
        }

        return null;
    }

    public function parameters()
    {
        return $this->hasMany(LabParameter::class, 'category_id');
    }

    public function packages()
    {
        return $this->hasMany(LabPackage::class, 'category_id');
    }

}