<?php

namespace App;

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

/**
 * @property mixed id
 */
class Country extends Model
{
    //use soft delete
    use SoftDeletes;

  protected $fillable = ['key'];
    /**
     * Return descriptions for article
     * @return HasMany
     */
    public function descriptions($language_id= null)
    {
        if ($language_id) {
            $data = $this->hasMany(CountryDescription::class)->where('language_id', $language_id)->first();
            if(!$data){
                $data = $this->hasMany(CountryDescription::class)->first();
            }
            
            return $data;
        }
        return $this->hasMany(CountryDescription::class);
    }
    public function cities() 
    {
        return $this->hasMany(City::class);
    }


  
}
