Files
citrus-cms/resources/views/cron/delete-no-paint-followup.blade.php
T
2026-04-28 21:15:09 +03:00

22 lines
674 B
PHP

<?php
use App\Models\PaintFollowUp;
use App\Models\LineList;
use Illuminate\Support\Facades\DB;
// Method 1: Using join which is more efficient than subquery
$deletedCount = DB::table('paint_follow_ups')
->join('line_lists', 'paint_follow_ups.line', '=', 'line_lists.line_no')
->where(function($query) {
$query->whereNull('line_lists.painting_cycle')
->orWhere('line_lists.painting_cycle', '');
});
if(isset($lineNumber)){
$deletedCount = $deletedCount->where('paint_follow_ups.line', $lineNumber);
}
$deletedCount = $deletedCount->delete();
Log::debug("$deletedCount rows deleted from paint_follow_ups table");
?>