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.

61 lines
1.4 KiB

<?php
namespace App\Console\Commands;
use App\Models\Course;
use App\Models\CourseSign;
use App\Models\EmailRecord;
use App\Models\EmailRecordUser;
use App\Models\User;
use App\Repositories\MeetRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Mail;
class AutoSchoolmate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'auto_schoolmate';
/**
* 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()
{
// 获取今天上课的课程
$today = date('Y-m-d');
$courses = Course::where('start_date', $today)->where('auto_schoolmate', 1)->get();
foreach ($courses as $course) {
// 获取报名通过的学员
$courseSigns = CourseSign::where('course_id', $course->id)->where('status', 1)->get();
// 用户设置成校友
User::whereIn('id', $courseSigns->pluck('user_id'))->update(['is_schoolmate' => 1]);
}
return $this->info('更新完成');
}
}