IMMREX7
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use DB;
use Carbon\Carbon;
use \App\Http\SendNotificationApi;
class BirthdayUpdate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:birthday';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send birthday wishes to the parents';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$school = DB::table('schools')->select('idSchool')->where('isBirthdayAutomatic',1)->get()->pluck('idSchool')->toArray();
DB::table('automatic_jobs')->insert([
'job_name' => "birthday",
'created_at' => Carbon::now()->format('Y-m-d H:i:s')
]);
$stds_birday = \App\AdmEntry::select('idStudent')->whereRaw("DATE_FORMAT((studentDob),'%m-%d') = DATE_FORMAT(NOW(),'%m-%d')")
->where('isActive','Y')
->whereIn('idSchool',$school)
->groupBy('idStudent')
->get()->pluck('idStudent')->toArray();
$reg_fids = DB::table('students')
->join('parents', 'students.father_mobile', '=', 'parents.mobile')
->select('parents.idFirebase')
->whereIn('students.idStudent', $stds_birday)
->get()->pluck('idFirebase')->toArray();
SendNotificationApi::sendNotification($reg_fids, "HAPPY BIRTHDAY! WISHING YOU A DAY FILLED WITH JOY AND MANY MORE SUCCESSFUL YEARS AHEAD. ENJOY YOUR SPECIAL DAY! - PRINCIPAL.");
$reg_ids = DB::table('students')
->join('parents', 'students.mother_mobile', '=', 'parents.mobile')
->select('parents.idFirebase')
->whereIn('students.idStudent', $stds_birday)
->get()->pluck('idFirebase')->toArray();
SendNotificationApi::sendNotification($reg_ids, "HAPPY BIRTHDAY! WISHING YOU A DAY FILLED WITH JOY AND MANY MORE SUCCESSFUL YEARS AHEAD. ENJOY YOUR SPECIAL DAY! - PRINCIPAL.");
}
}
Copyright © 2021 -