<?php

namespace Yajny\EventsYj\Models;

use Illuminate\Database\Eloquent\Model;
use Yajny\EventsYj\Models\AdminNotification;
use Yajny\EventsYj\Traits\DynamicTemplate;

class AdminAlertTemplate extends Model
{
    use DynamicTemplate;
    //
    public $table = 'tb_alert_templates';
    public $timestamps = false;
    
    public $changeTitle  = false;

    public function notifyAdmin($event)
    {   
       
        foreach( $event as $eveKey => $eveObj  )
        {
            if($eveObj)
           $this->templateVarReplace($eveKey,$eveObj);
            
        }
        
       
      $this->webNotify();

    }
   
    protected function webNotify(){
        $adminNotification = new AdminNotification(['userid'=>1,'url'=>$this->url,'title'=>$this->title,'note'=>$this->template]);
        $adminNotification->save();
    }
}
