HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/app/Rating.php
<?php

namespace App;

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

class Rating extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'doctor_rating', 'digimed_rating', 'comment',
    ];

    public function getData()
    {
        $created_at = Carbon::parse($this->created_at)->format('Y-m-d H:i:s');

        return [

            'id' => $this->id,
            'doctor' => $this->doctor()->first()->basicProfile(),
            'patient' => $this->patient()->first()->basicProfile(),
            'appointment_id' => $this->appointment_id,
            'doctor_rating' => $this->doctor_rating,
            'digimed_rating' => $this->digimed_rating,
            'comment' => $this->comment,
            //'created_at' => date('d/m/Y',strtotime($this->created_at)),
            'created_at'=>$created_at,
        ];
    }

    public function doctor(): BelongsTo
    {
        return $this->belongsTo(User::class, 'doctor_id')->withTrashed();
    }

    public function patient(): BelongsTo
    {
        return $this->belongsTo(User::class, 'patient_id', 'id')->withTrashed();
    }

    public function appointment(): BelongsTo
    {
        return $this->belongsTo(Appointment::class, 'appointment_id', 'id')->withTrashed();
    }
}