Files
citrus-cms/resources/views/admin-ajax/welder-location.blade.php
T
2026-04-28 21:15:09 +03:00

48 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
use App\Models\WelderLocation;
$naksWelders = db("naks_welders")->get();
foreach($naksWelders AS $naksWelder) {
if($naksWelder->welder_id != "") {
$updateData = [
'naks_id'=>$naksWelder->welder_id,
'subcontructor'=>$naksWelder->company,
'name_surname'=>$naksWelder->welder_name_en,
];
$whereData = [
'naks_id'=>$naksWelder->welder_id
];
WelderLocation::updateOrCreate($whereData, $updateData);
}
}
// Welder_tests tablosunda olmayan kayıtları welder_locations'dan silme
$existingWelderTests = db("welder_tests")
->distinct()
->pluck('naks_id')
->toArray();
WelderLocation::whereNotIn('naks_id', $existingWelderTests)->delete();
$welderLocations = WelderLocation::groupBy("naks_id")->get();
foreach($welderLocations AS $welderLocation) {
db("naks_welders")
->where("welder_id", $welderLocation->naks_id)
->update([
'status' => $welderLocation->location
]);
db("welder_tests")
->where("naks_id", $welderLocation->naks_id)
->update([
'shop_or_field' => $welderLocation->location
]);
}
echo json_encode_tr($welderLocations);
?>