File: /var/www/html/sarvodayahospital/app/Models/ResearchPublication.php
<?php
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
class ResearchPublication extends Model
{
public function getDescriptionAttribute($value) {
return html_entity_decode(html_entity_decode($value));
}
public function doctorInfo()
{
return $this->belongsTo(Doctor::class, 'DoctorID', 'id');
}
public function speciality()
{
return $this->belongsTo(Speciality::class, 'SpecialityID', 'id');
}
public function treatment()
{
return $this->belongsTo(Treatment::class, 'TreatmentID', 'id');
}
public function media()
{
return $this->hasOneThrough(
Media::class,
MediaMorph::class,
'related_id',
'id',
'id',
'upload_file_id'
)
->where('related_type', 'research_publications')
->where('field', 'Attachment')
->orderBy('order')
->select('upload_file.id', 'name', 'url', 'formats');
}
public function seoComponent()
{
return $this->hasOneThrough(
SEOComponent::class,
ResearchPublicationComponent::class,
'research_publication_id',
'id',
'id',
'component_id'
)->where('field', 'SEO')
->where('component_type', 'components_seo_seos');
}
public function getResearchDateAttribute($value)
{
return Carbon::parse($value)->format('M d, Y');
}
}