Updates for check_version

This commit is contained in:
David Bomba 2024-07-09 07:32:13 +10:00
parent 42da98a132
commit 045dbac6ff
4 changed files with 51 additions and 7 deletions

View File

@ -181,6 +181,9 @@ class SelfUpdateController extends BaseController
public function checkVersion()
{
if(Ninja::isHosted())
return '5.10.SaaS';
return trim(file_get_contents(config('ninja.version_url')));
}

View File

@ -53,12 +53,8 @@ class VendorRepository extends BaseRepository
$vendor->saveQuietly();
if ($vendor->number == '' || ! $vendor->number) {
$vendor->number = $this->getNextVendorNumber($vendor);
}
$vendor->saveQuietly();
$vendor->service()->applyNumber();
if (isset($data['contacts']) || $vendor->contacts()->count() == 0) {
$this->contact_repo->save($data, $vendor);
}

View File

@ -169,7 +169,7 @@ class ClientService
} catch (QueryException $e) {
$x++;
if ($x > 10) {
if ($x > 50) {
$this->completed = false;
}
}

View File

@ -12,10 +12,55 @@
namespace App\Services\Vendor;
use App\Models\Vendor;
use App\Utils\Traits\GeneratesCounter;
use Illuminate\Database\QueryException;
class VendorService
{
use GeneratesCounter;
private bool $completed = true;
public function __construct(public Vendor $vendor)
{
}
public function applyNumber(): self
{
$x = 1;
if(isset($this->vendor->number)) {
return $this;
}
do {
try {
$this->vendor->number = $this->getNextVendorNumber($this->vendor);
$this->vendor->saveQuietly();
$this->completed = false;
} catch (QueryException $e) {
$x++;
if ($x > 50) {
$this->completed = false;
}
}
} while ($this->completed);
return $this;
}
/**
* Saves the vendor instance
*
* @return Vendor The Vendor Model
*/
public function save(): Vendor
{
$this->vendor->saveQuietly();
return $this->vendor->fresh();
}
}