parent
20e0730f95
commit
b8f0f151bf
@ -0,0 +1,60 @@
|
||||
<?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('更新完成');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('courses', function (Blueprint $table) {
|
||||
// 已审核学员是否自动进入校友库
|
||||
$table->boolean('auto_schoolmate')->default(false)->comment('已审核学员是否自动进入校友库0否1是');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('courses', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
// 是否黑名单
|
||||
$table->boolean('is_black')->default(0)->comment('是否黑名单');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Reference in new issue