<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\PaymentGateway;
use App\Models\Currency;
use App\Models\LeadData;
use App\User;

class Leads extends Model
{
    use SoftDeletes;
    
    protected $table = 'leads';

    protected $dates = ['deleted_at'];

    public function leadData(){
        return $this->hasMany(LeadData::class, 'lead_id');
    }
    public function deleteTestLeads($wordsToDelete){
        return Leads::where(function($query) use ($wordsToDelete) {
            foreach ($wordsToDelete as $word) {
                $query->orWhere('email', 'like', "%$word%")
                        ->orWhere('name', 'like', "%$word%");
            }
        })
        ->delete();
    }
}
