Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/cms.ncriptech.com/app/Console/Commands/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php namespace App\Console\Commands; use Illuminate\Support\Facades\Notification; use App\Notifications\ContentNotification; use Illuminate\Console\Command; use App\Models\Content; use App\Models\Student; use Carbon\Carbon; class ContentPublishDate extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'content:send'; /** * The console command description. * * @var string */ protected $description = 'Schedul Content Send!'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $today_date = Carbon::parse(Carbon::today())->format('Y-m-d'); $contents = Content::where('status', '1')->where('date', $today_date)->get(); foreach($contents as $content){ $students = Student::where('status', '1'); if($content->faculty != 0){ $students->with('program')->whereHas('program', function ($query) use ($faculty){ $query->where('faculty_id', $content->faculty); }); } $students->with('currentEnroll')->whereHas('currentEnroll', function ($query) use ($program, $session, $semester, $section){ if($content->program != 0){ $query->where('program_id', $content->program); } if($content->session != 0){ $query->where('session_id', $content->session); } if($content->semester != 0){ $query->where('semester_id', $content->semester); } if($content->section != 0){ $query->where('section_id', $content->section); } $query->where('status', '1'); }); $all_students = $students->orderBy('student_id', 'desc')->get(); // Notification Data $data = [ 'id' => $content->id, 'title' => $content->title, 'type' => 'content' ]; Notification::send($all_students, new ContentNotification($data)); } } }