File: /var/www/html/sarvodayahospital/app/Models/PatientEducation.php
<?php
namespace App\Models;
use App\Scopes\isActiveScope;
use App\Scopes\isPublishedScope;
use Illuminate\Database\Eloquent\Model;
class PatientEducation extends Model
{
protected $table = 'patient_educations';
protected static function booted()
{
static::addGlobalScope(new isActiveScope());
static::addGlobalScope(new isPublishedScope());
}
public function faqs()
{
return $this->hasManyThrough(
AccordionComponent::class,
PatientEducationComponent::class,
'patient_education_id',
'id',
'id',
'component_id'
)->where('field', 'Accordion')
->where('component_type', 'components_accordion_accordions')
->orderBy('order');
}
public function seoComponent()
{
return $this->hasOneThrough(
SEOComponent::class,
PatientEducationComponent::class,
'patient_education_id',
'id',
'id',
'component_id'
)->where('field', 'SEO')
->where('component_type', 'components_seo_seos');
}
public function organs()
{
return $this->BelongsToMany(
Organ::class,
'patient_educations__organs',
'patient_education_id',
'organ_id'
);
}
}