updateTicket.php 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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. protected $signature = 'updateTicket';
  9. protected $description = '更新工单';
  10. public function handle(): void {
  11. Log::info('----------------------------【更新工单】开始----------------------------');
  12. // 获取管理员
  13. foreach(User::whereIsAdmin(1)->get() as $admin){
  14. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】开始----------------------------');
  15. // 获取该管理回复过的工单, 更新工单
  16. foreach(TicketReply::whereUserId($admin->id)->get() as $reply){
  17. $ret = TicketReply::whereId($reply->id)->update(['user_id' => 0, 'admin_id' => $admin->id]);
  18. if($ret){
  19. Log::info('--- 管理员:'.$admin->email.'回复子单ID:'.$reply->id.' ---');
  20. }else{
  21. Log::error('更新回复子单ID:【'.$reply->id.'】 失败!');
  22. }
  23. }
  24. Log::info('----------------------------【更新管理员'.$admin->id.'回复工单】完成----------------------------');
  25. }
  26. Log::info('----------------------------【更新工单】结束----------------------------');
  27. }
  28. }