Edit File: Rate.php
<?php namespace App\Models; use App\Models\OnlineLearning\TeachingOrder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; class Rate extends Model { use HasFactory; protected $fillable = [ 'rate', 'ratedable_id', 'ratedable_type', 'ratingable_id', 'ratingable_type', 'message', 'order_id' ]; public $appends = ['title_message_for_dashboard']; // relation with user and provider public function ratingable() { return $this->morphTo(); } public function ratedable() { return $this->morphTo(); } public function order() { return $this->belongsTo(Order::class); } public function getTitleMessageForDashboardAttribute(): string { if ($this->ratedable_type == User::class && $this->ratingable_type == Delegate::class) { $message = __('admin.user_rates_from_delegate'); } if ($this->ratedable_type == Provider::class && $this->ratingable_type == User::class) { $message = __('admin.provider_rates_from_user'); } if($this->ratedable_type == Provider::class && $this->ratingable_type == Delegate::class) { $message = __('admin.provider_rates_from_delegate'); } if ($this->ratedable_type == Delegate::class && $this->ratingable_type == User::class) { $message = __('admin.delegate_rates_from_user'); } if($this->ratedable_type == Delegate::class && $this->ratingable_type == Provider::class) { $message = __('admin.delegate_rates_from_provider'); } return $message; } }
Back to File Manager