<?php

namespace App\EloquentFilters\Airtime_sending_record;

use Fouladgar\EloquentBuilder\Support\Foundation\Contracts\Filter;
use Illuminate\Database\Eloquent\Builder;
use App\Models\atmodels\Airtime_contact;
class GroupFilter extends Filter
{
    /**
     * Apply the condition to the query.
     *
     * @param Builder $builder
     * @param mixed $value
     *
     * @return Builder
     */
    public function apply(Builder $builder, $value): Builder
    {
        //gete contacts
        $groupcontacts = Airtime_contact::where('group_id',$value)->pluck('contact');
        return $builder->whereIn('recipient', $groupcontacts);
    }
}
