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');
}
}