|
|
|
@ -34,25 +34,35 @@ class PetiController extends Controller
|
|
|
|
|
$search = $request->input('search') ?? ''; |
|
|
|
|
if ($search) { |
|
|
|
|
$query->where(function ($q) use ($search) { |
|
|
|
|
$q->where('fix_lot', 'like', "%$search%") |
|
|
|
|
->orWhere('created_by', 'like', "%$search%") |
|
|
|
|
$q->where('fix_lot', 'like', "%$search%") // mencari fix lot |
|
|
|
|
// ->orWhere('created_by', 'like', "%$search%") |
|
|
|
|
->orWhereHas('customer', function ($customerQuery) use ($search) { |
|
|
|
|
$customerQuery->where('name', 'like', "%$search%") |
|
|
|
|
->orWhere('code_customer', 'like', "%$search%") |
|
|
|
|
->orWhere('lot_no', 'like', "%$search%"); |
|
|
|
|
$customerQuery->where('name', 'like', "%$search%") //mencari nama customer |
|
|
|
|
->orWhere('code_customer', 'like', "%$search%") //mencari kode customer |
|
|
|
|
->orWhere('lot_no', 'like', "%$search%"); //mencari lot no |
|
|
|
|
}) |
|
|
|
|
->orWhereHas('warehouse', function ($warehouseQuery) use ($search) { |
|
|
|
|
$warehouseQuery->where('name', 'like', "%$search%"); |
|
|
|
|
$warehouseQuery->where('name', 'like', "%$search%"); //mencari nama gudang |
|
|
|
|
}) |
|
|
|
|
->orWhereHas('tipe_peti', function ($tipePetiQuery) use ($search) { |
|
|
|
|
$tipePetiQuery->where('type', 'like', "%$search%") |
|
|
|
|
->orWhere('size_peti', 'like', "%$search%"); |
|
|
|
|
$tipePetiQuery->where('type', 'like', "%$search%") //mencari type |
|
|
|
|
->orWhere('size_peti', 'like', "%$search%"); //mencari ukuran peti |
|
|
|
|
}) |
|
|
|
|
->orWhereHas('kondisipeti', function ($kondisiPetiQuery) use ($search) { |
|
|
|
|
$kondisiPetiQuery->where('nama_kondisi', 'like', "%$search%"); |
|
|
|
|
$kondisiPetiQuery->where('nama_kondisi', 'like', "%$search%"); //mencari nama kondisi |
|
|
|
|
}) |
|
|
|
|
->orWhere('packing_no', 'like', "%$search%") |
|
|
|
|
->orWhere('status', 'like', "%$search%"); |
|
|
|
|
->orWhere(function ($statusQuery) use ($search) { |
|
|
|
|
if (strtolower($search) === 'ada') { |
|
|
|
|
$statusQuery->where('status_isi', 1); |
|
|
|
|
} elseif (strtolower($search) === 'tidak ada') { |
|
|
|
|
$statusQuery->where('status_isi', 0); |
|
|
|
|
} else { |
|
|
|
|
$statusQuery->where('status_isi', 'like', "%$search%"); |
|
|
|
|
} |
|
|
|
|
}) //mencari status isi ADA atau TIDAK ADA |
|
|
|
|
->orWhere('warna', 'like', "%$search%") |
|
|
|
|
->orWhere('packing_no', 'like', "%$search%"); //mencari packing no |
|
|
|
|
// ->orWhere('status', 'like', "%$search%"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|