You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB

2 months ago
<?php
namespace App\Console\Commands;
use App\Jobs\SendCourseDoor;
use App\Models\Course;
use App\Models\CourseSign;
use App\Models\User;
use App\Notifications\AuditNotify;
use App\Notifications\BirthdayNotify;
use App\Repositories\MeetRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Notification;
class UpdateCourseSignDoor extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update_course_sign_door';
/**
* The console command description.
*
* @var string
*/
protected $description = '批量更新学员的门禁权限';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$courses = Course::where('status', 1)
->whereIn('id', [97, 99])
->get();
foreach ($courses as $course) {
$courseSigns = CourseSign::where('course_id', $course->id)->where('status', 1)->get();
foreach ($courseSigns as $courseSign) {
dispatch((new SendCourseDoor($courseSign)));
$this->info('更新学员' . $courseSign->user->name . '的门禁权限');
}
}
return $this->info('更新完成');
}
}