regenerate customers marking

This commit is contained in:
omair saleh
2021-08-30 17:52:10 +08:00
parent 53575cf59a
commit fae47f4a75
+20 -16
View File
@@ -70,21 +70,25 @@ Route::get('/customer/{marking}', function ($marking) {
Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download');
Route::get('/test', function(){
dd(\App\Models\OldOrders::first());
$companyConnections = CompanyConnection::all();
foreach ($companyConnections as $connection){
$company = $connection->invitee;
$oldCompany = OldCompany::where('name', 'LIKE', '%'.$company->name.'%')->first();
if ($oldCompany){
$marking = explode("CIEF/", $oldCompany->marking);
$marking = str_replace(' ', '', str_replace('/', '', $marking[1]));
$connection->invitee_reference = $marking;
} else {
$connection->invitee_reference = mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate();
}
$connection->save();
$connection = mysqli_connect(env('DB_HOST_IZYIM'), env('DB_USERNAME_IZYIM'), env('DB_PASSWORD_IZYIM'), env('DB_DATABASE_IZYIM'));
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
die("Connected successfully");
// $companyConnections = CompanyConnection::all();
// foreach ($companyConnections as $connection){
// $company = $connection->invitee;
// $oldCompany = OldCompany::where('name', 'LIKE', '%'.$company->name.'%')->first();
// if ($oldCompany){
// $marking = explode("CIEF/", $oldCompany->marking);
// $marking = str_replace(' ', '', str_replace('/', '', $marking[1]));
// $connection->invitee_reference = $marking;
//
// } else {
// $connection->invitee_reference = mt_rand(1000, 9999).(new GeneratesInitials())->name($company->name)->length(3)->generate();
// }
//
// $connection->save();
// }
})->name('test');