22 lines
674 B
PHP
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");
|
|
?>
|