<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class AcademicFormation extends Model
{
    use HasFactory;
    protected $fillable = [
        'user_id',
        'institution_name',
        'educational_level_id',
        'study_area',
        'status',
        'modality',
        'initial_date_month',
        'initial_date_year',
        'final_date_month',
        'final_date_year',
        'academic_formation_support',
        'professional_card_support'
    ];

    public function educational_level(){
        return $this->belongsTo('App\Models\Educational_level');
    }

    public function getEducationalLevelNameAttribute(){
        return DB::table('educational_levels')->where('id', $this->educational_level_id)->value('name');
    }
    public function getStatusNameAttribute()
    {
        return DataTypeStatusAcademic($this->status);
    }
    public function getModalityNameAttribute()
    {
        return DataTypeModalityAcademic($this->modality);
    }
    public function getInitialDateMonthNameAttribute()
    {
        return DataTypeMonth($this->initial_date_month);
    }
    public function getFinalDateMonthNameAttribute()
    {
        return DataTypeMonth($this->final_date_month);
    }


}
