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

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;

class Lab extends Model
{
    use SoftDeletes;

    protected $fillable = ['name', 'user_id', 'clinic_id', 'created_by', 'updated_by', 'deleted_by','status'];

    protected $hidden = ['created_by', 'updated_by', 'deleted_by', 'deleted_at', 'updated_at'];

    protected $appends = ['owner_detail'];

   
    public function owner(): HasOne
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function getOwnerDetailAttribute()
    {
        return User::find($this->user_id);
    }
    public function orders()
    {
        return $this->hasMany(LabOrder::class, 'lab_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id')->withTrashed();
    }    

}