updateTicket.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\TicketReply;
  4. use App\Models\User;
  5. use Illuminate\Console\Command;
  6. use Log;
  7. class updateTicket extends Command
  8. {
  9. protected $signature = 'updateTicket';
  10. protected $description = '更新工单';
  11. public function handle(): void
  12. {
  13. Log::info('----------------------------【更新工单】开始----------------------------');
  14. // 获取管理员
  15. foreach (User::whereIsAdmin(1)->get() as $admin) {
  16. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】开始----------------------------');
  17. // 获取该管理回复过的工单, 更新工单
  18. foreach (TicketReply::whereUserId($admin->id)->get() as $reply) {
  19. $ret = TicketReply::whereId($reply->id)->update(['user_id' => 0, 'admin_id' => $admin->id]);
  20. if ($ret) {
  21. Log::info('--- 管理员:'.$admin->email.'回复子单ID:'.$reply->id.' ---');
  22. } else {
  23. Log::error('更新回复子单ID:【'.$reply->id.'】 失败!');
  24. }
  25. }
  26. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】完成----------------------------');
  27. }
  28. Log::info('----------------------------【更新工单】结束----------------------------');
  29. }
  30. }