<?php

namespace Modules\Notification\Models;

use Modules\Notification\Models\NotificationDescription;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Modules\Country\Models\Country;

class Notification extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'status','user_id','read_at','target_id'
    ];


    /**
     * Get current description of the the Room
     * @return HasOne
     */

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

    public function getDateAttribute()
    {
        $date = date('d',strtotime($this->created_at));
        $date .= ' '.__('web.monthes.'.date('m',strtotime($this->created_at)));
        $date .= ' '.date('Y',strtotime($this->created_at));
        return $date;
    }
    public function getTimeAttribute()
    {
        $date = date('g:i a',strtotime($this->created_at));
        return $date;
    }
}
