<?php

namespace App;

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

class About extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'home_image_1',
        'home_image_2',
        'about_image_1',
        'about_image_2',
        'about_logo',
        'about_icon_1',
        'about_icon_2',
        ];


    public function descriptions()
    {
        return $this->hasMany(AboutDescription::class)->where('language_id', currentLanguage()->id);
    }

    public static function getAbout()
    {
        $language_id = currentLanguage()->id;
        return self::first()->join('about_descriptions as ad', 'ad.about_id', 'abouts.id')
            ->where('ad.language_id', $language_id)
            ->select(['abouts.*', 'ad.*'])->first();
    }
}
