Files
citrus-cms/resources/views/cron/pdf-db-wps-sync.blade.php
T
2026-04-28 21:15:09 +03:00

69 lines
1.5 KiB
PHP

<?php
$table = "w_p_s";
$mainPath = "003_Welding_Database/0005_WPS";
$nullDownload = db($table);
$nullDownload = $nullDownload->get();
//dump($nullDownload->count());
DB::beginTransaction();
$say = 0;
$k = 0;
Log::debug("📄$table PDF Link to DB Start " . simdi());
try {
foreach($nullDownload AS $ne) {
$data = "{$ne->details}";
$data = str_replace("/", "*", $data);
$data = str_replace(" ", "*", $data);
if(trim($data) != "") {
$path = "storage/documents/$mainPath/*$data*";
$searchPDF = glob($path);
$updateData = [];
$updateData['download'] = null;
if(isset($searchPDF[0])) {
$updateData['download'] = $searchPDF[0];
}
// //dump($updateData);
db($table)
->where("id", $ne->id)
->update($updateData);
$k++;
if($say == $commitSize) {
DB::commit();
DB::beginTransaction();
$say = 0;
}
$say++;
}
}
DB::commit();
Log::debug("$table update PDF link for $k rows");
//dump("$table update PDF link for $k rows");
} catch (\Throwable $th) {
DB::rollback();
Log::error("not update PDF links " . $th->getMessage());
////dump($th->getMessage());
}
Log::debug("📄$table PDF Link to DB Finish " . simdi());
?>