command->info('Delete all anomaly project in purchase order...'); $datas = PurchaseOrder::whereDoesntHave('project', function ($q) { $q->where('service_category_id', 1); }) ->whereNotnull('project_id') ->get(); if (count($datas) < 1) { $this->command->info('No matching data found'); return; } $this->command->getOutput()->progressStart($datas->count()); DB::transaction(function () use (&$datas) { foreach ($datas as $po) { PurchaseOrder::where('id', $po->id)->delete(); $this->command->getOutput()->progressAdvance(); } }); $this->command->getOutput()->progressFinish(); } }