<?php

namespace App\Jobs;

use App\Models\JobsHistory;
use App\Models\ScheduleSMS;
use App\Models\SMSActivity;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Carbon\Carbon;

class ScheduleProcess implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;


    protected $scheduledMessagesIds;

    public function __construct($scheduledMessagesIds)
    {
        $this->scheduledMessagesIds = $scheduledMessagesIds;
    }

    public function handle()
    {
        $scheduledSmses = ScheduleSMS::whereIn('id', $this->scheduledMessagesIds)->get();

        foreach ($scheduledSmses as $sms) {
            dispatch(new ScheduleSmsJob([
                'sms_type' => $data->sms_type,
                'user_id' => $data->user_id,
                'type_id' => $number->type_id,
                'type' => $number->type,
                'job_type' => 2,
                'date' => date('Y-m-d'),
                'sender_id' => $selectedSender->id,
            ], new JobsHistory()));
        }
    }


}
