<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class Faq extends Model
{
    use SoftDeletes;
    public function descriptions() :HasMany
    {
        return $this->hasMany(FaqDescription::class);
    }

    public static function withDescription()
    {
        return self::join('faq_descriptions as fd', 'fd.faq_id', 'faqs.id')
                ->where('fd.language_id', currentLanguage()->id)
                ->select(['fd.question', 'fd.answer'])->cursor() ?? [];
    }
}
