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

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;

/**
 * App\PrescriptionDetails
 *
 * @property mixed $route_id
 * @property mixed $route
 */
class PrescriptionDetails extends Model
{
    use SoftDeletes;

    protected $fillable = ['id', 'appointment_id', 'prescription_id', 'product_name', 'dose', 'frequency', 'duration', 'route', 'timing', 'other_comments', 'type_value', 'type_value', 'created_at'];

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

    protected $appends = ['route_data'];

    public function getRouteDataAttribute(){
        // $str = [];
        if($this->prescription_id != ""){
            // $items = explode(",",$this->route_id);
            $out = PrescriptionRouteLists::where('prescription_id',$this->prescription_id)->get()->toArray();
            return $out;
        }
        // return $str;
        // return $this->hasMany(PrescriptionRouteLists::class, 'prescription_id', 'prescription_id');
    }

    public function prescription(): BelongsTo
    {
        return $this->belongsTo(Prescription::class, 'id', 'prescription_id');
    }

}