<?php

namespace App\Jobs;

use App\Models\MessageModel;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

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

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public $judul;
    public $pesan;
    public $no;
    public $siaga;
    public $perangkat;
    public $group;
    public function __construct($judul, $pesan, $no, $siaga, $perangkat, $group)
    {
        $this->judul = $judul;
        $this->pesan = $pesan;
        $this->no = $no;
        $this->siaga = $siaga;
        $this->perangkat = $perangkat;
        $this->group = $group;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $message = new MessageModel();
        $message->uuid_device_results = null;
        $message->title = $this->judul;
        $message->message = $this->pesan;
        $message->date_time = now();
        $message->send_by = "Manual";
        $message->uuid_user = $this->no;
        $message->siaga = $this->siaga;
        $message->uuid_device = $this->perangkat;
        $message->uuid_group = $this->group;
        $message->save();
    }
}
