regenerate customers marking

This commit is contained in:
omair saleh
2021-08-30 16:07:10 +08:00
parent 3f48d85e31
commit 0a32af0dab
+18 -1
View File
@@ -1,5 +1,6 @@
<?php
use App\Classes\General\Services\GeneratesInitials;
use App\Models\CompanyConnection;
use App\Models\Order;
use Illuminate\Support\Facades\Route;
@@ -66,4 +67,20 @@ Route::get('/customer/{marking}', function ($marking) {
Route::get('/order/{id}/download', 'Orders\DownloadOrderQrPdfController@download')->name('order.qr.download');
Route::get('/test', 'TestController@test')->name('test');
Route::get('/test', function(){
$companyConnections = CompanyConnection::all();
foreach ($companyConnections as $connection){
$company = $connection->invitee;
$oldCompany = \App\Models\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');