<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class EmailLog extends Model
{
    //


    public function updateTable($filters) {

        
       
        $query = EmailLog::where([['id','!=',null]])
       
        ;

        foreach($filters as $key => $val) 
        {
            if($key == 'status'){
                if($val == 2){
                $query = $query->where('status',0);
                }
                else{
                    $query = $query->where('status',1);
                }
            }
            elseif($key == 'email')
                $query = $query->where('receiver_email','like',$val);
            elseif($key == 'title')
                $query = $query->where('title','like',$val);
               
           
        }
      
    
        $result = $query->get();
     
        return ['email_log'=>$result];
    }
}
