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