Files
water-back/modules/User/Console/Commands/AutoRemindUserCase.php
2023-01-12 14:47:38 +08:00

58 lines
1.3 KiB
PHP

<?php
namespace Modules\User\Console\Commands;
use App\Notifications\SystemUpdateCase;
use Illuminate\Console\Command;
use Modules\User\Models\Sign;
class AutoRemindUserCase extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'xuanchen:auto-remind-user-case';
/**
* 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()
{
Sign::query()
->whereHas('user', function ($q) {
$q->whereHas('identityMiddle', function ($q) {
$q->whereIn('identity_id', [2, 3, 4, 5, 6]);
});
})
->where('need_case', 1)
->where('is_finish', 1)
->chunkById(1000, function ($signs) {
foreach ($signs as $key => $sign) {
$sign->user->notify(new SystemUpdateCase());
}
});
}
}