<?php

namespace App;

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

/**
 * @property mixed currentDescription
 */
class About extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'about_image_1',
        'about_image_2',
        'video_image',
        'video_url',
        'client_numbers',
        'consulting_numbers',
        'cases_numbers',
        'documentation_numbers',
//        'vision_image',
//        'mission_image',
//        'message_image',
        ];

    public function getSlugTextAttribute() : ?string
    {
        return str_slug(strtolower($this->currentDescription->slug));
    }

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

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

}
