pintu2/app/Jobs/layananPengajuanDpuDpaJob.php

95 lines
5.0 KiB
PHP
Raw Normal View History

2024-03-07 18:13:09 +07:00
<?php
namespace App\Jobs;
use App\Models\PengajuanDpuDpa;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Ixudra\Curl\Facades\Curl;
use Spatie\Permission\Models\Role;
class layananPengajuanDpuDpaJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $data;
public function __construct($data)
{
$this->data = $data;
}
/**
* Execute the job.
*/
public function handle(): void
{
if($this->data['jenis']==="penolakan"){
$text = "BETA\n".
"Penolakan Pengajuan Mahasiswa: ".$this->data['nama']."\n".
"Dengan Email : ".$this->data['email']."\n\n".
"Alasan : ".$this->data['alasan'];
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
elseif($this->data['jenis'] == 'dpu'){
$data = PengajuanDpuDpa::where('pengajuan_dpu_dpas.id',$this->data['id'])->select('mahasiswas.nama','mahasiswas.nim','mahasiswas.judul_seminar_proposal','mahasiswas.dosen_dpu_id','users.nama_gelar','users.email')->join('mahasiswas','mahasiswas.id','=','mahasiswas_id')->join('users','users.id','=','dosen_dpu_id')->first();
$text = "BETA\n".
"Kirim Pengajuan A/N Mahasiswa: ".$data->nama."\n".
"Kepada DPU : ".$data->nama_gelar."\n\n".
"Alamat Email : ".$data->email;
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
elseif($this->data['jenis'] == 'dpa'){
$data = PengajuanDpuDpa::where('pengajuan_dpu_dpas.id',$this->data['id'])->select('mahasiswas.nama','mahasiswas.nim','mahasiswas.judul_seminar_proposal','mahasiswas.dosen_dpa_id','users.nama_gelar','users.email')->join('mahasiswas','mahasiswas.id','=','mahasiswas_id')->join('users','users.id','=','dosen_dpa_id')->first();
$text = "BETA\n".
"Kirim Pengajuan A/N Mahasiswa: ".$data->nama."\n".
"Kepada DPA : ".$data->nama_gelar."\n\n".
"Alamat Email : ".$data->email;
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
elseif($this->data['jenis'] == 'kombi'){
$kombiRole = Role::findByName('Ketua Kombi')->users;
$data = PengajuanDpuDpa::where('pengajuan_dpu_dpas.id',$this->data['id'])->select('mahasiswas.nama','mahasiswas.nim','mahasiswas.judul_seminar_proposal')->join('mahasiswas','mahasiswas.id','=','mahasiswas_id')->first();
$text = "BETA\n".
"Kirim Pengajuan A/N Mahasiswa: ".$data->nama."\n".
"Kepada Komisi Bimbingan : ".$kombiRole[0]->nama_gelar."\n\n".
"Alamat Email : ".$kombiRole[0]->email;
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
elseif($this->data['jenis'] == 'mahasiswa'){
$data = PengajuanDpuDpa::where('pengajuan_dpu_dpas.id',$this->data['id'])->select('mahasiswas.nama','mahasiswas.nim','mahasiswas.judul_seminar_proposal','mahasiswas.email')->join('mahasiswas','mahasiswas.id','=','mahasiswas_id')->first();
$text = "BETA\n".
"Kirim Pengajuan A/N Mahasiswa: ".$data->nama."\n".
"Kepada Mahasiswa : ".$data->nama."\n\n".
"Alamat Email : ".$data->email;
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
elseif($this->data['jenis'] == 'mahasiswa selesai'){
$data = PengajuanDpuDpa::where('pengajuan_dpu_dpas.id',$this->data['id'])->select('mahasiswas.nama','mahasiswas.nim','mahasiswas.judul_seminar_proposal','mahasiswas.email')->join('mahasiswas','mahasiswas.id','=','mahasiswas_id')->first();
$text = "BETA\n".
"Kirim Notifikasi Pengajuan Selesai A/N Mahasiswa: ".$data->nama."\n".
"Kepada Mahasiswa : ".$data->nama."\n\n".
"Alamat Email : ".$data->email;
Curl::to('https://api.telegram.org/bot6161516511:AAGZhf_o31HupIogjUbEgvwjukes-3P3zPo/sendMessage')
->withData( array( 'chat_id' => '-1001903808078', 'text' => $text, 'parse_mode' => 'Markdown') )
->get();
}
}
}