File: /var/www/vhost/disk-apps/alq-cali.bikenow.co/app/Services/ErpService.php
<?php
namespace App\Services;
use App\ErpParameter;
use Illuminate\Support\Facades\Cache;
class ErpService
{
public function isSynchronizingWithERP($erpReference)
{
$erpSync = Cache::get('erp_sync');
return $erpSync && in_array($erpReference, $erpSync);
}
public function synchronizing($erpReference)
{
$erpSync = Cache::get('erp_sync') ?? [];
array_push($erpSync, $erpReference);
Cache::put('erp_sync', $erpSync, config('cache.short_time'));
}
public function canSync($reference, $ERPRepository, $syncParameter)
{
$erpSync = ErpParameter::where('key', $syncParameter)->first();
if (!$erpSync || $erpSync->value == 'false') {
return false;
}
if ($this->isSynchronizingWithERP($reference)) {
return false;
}
return true;
}
}