diff --git a/app/Console/Commands/TypeCheck.php b/app/Console/Commands/TypeCheck.php index d26785b0ad4b..7a57791eb4e8 100644 --- a/app/Console/Commands/TypeCheck.php +++ b/app/Console/Commands/TypeCheck.php @@ -122,7 +122,7 @@ class TypeCheck extends Command $client->save(); }); - Company::cursor()->each(function ($company) { + Company::query()->cursor()->each(function ($company) { $this->logMessage("Checking company {$company->id}"); $company->saveSettings($company->settings, $company); }); diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 6d3eb9c0335a..98750aa683b9 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -53,7 +53,7 @@ class QuoteController extends Controller { /* If the quote is expired, convert the status here */ - $invitation = $quote->invitations()->where('client_contact_id', auth()->user()->id)->first(); + $invitation = $quote->invitations()->where('client_contact_id', auth()->guard('contact')->user()->id)->first(); $data = [ 'quote' => $quote, diff --git a/app/Http/Controllers/SelfUpdateController.php b/app/Http/Controllers/SelfUpdateController.php index 12fd890840a6..f304482fac6b 100644 --- a/app/Http/Controllers/SelfUpdateController.php +++ b/app/Http/Controllers/SelfUpdateController.php @@ -53,7 +53,7 @@ class SelfUpdateController extends BaseController nlog('Test filesystem is writable'); - // $this->testWritable(); + $this->testWritable(); nlog('Clear cache directory'); @@ -61,12 +61,22 @@ class SelfUpdateController extends BaseController nlog('copying release file'); - if (copy($this->getDownloadUrl(), storage_path("app/{$this->filename}"))) { - nlog('Copied file from URL'); - } else { + $file_headers = @get_headers($this->getDownloadUrl()); + + if (stripos($file_headers[0], "404 Not Found") >0 || (stripos($file_headers[0], "302 Found") > 0 && stripos($file_headers[7], "404 Not Found") > 0)) { return response()->json(['message' => 'Download not yet available. Please try again shortly.'], 410); } + try { + if (copy($this->getDownloadUrl(), storage_path("app/{$this->filename}"))) { + nlog('Copied file from URL'); + } + } + catch(\Exception $e) { + nlog($e->getMessage()); + return response()->json(['message' => 'File exists on the server, however there was a problem downloading and copying to the local filesystem'], 500); + } + nlog('Finished copying'); $file = Storage::disk('local')->path($this->filename); diff --git a/phpstan.neon b/phpstan.neon index 6bc4f9205594..13799a2a91b7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -7,13 +7,13 @@ parameters: - 'app/' excludePaths: - 'vendor/' + - 'resources/views/*' - 'app/Jobs/Ninja/*' - 'app/Models/Presenters/*' - 'app/Console/Commands/*' - 'app/DataMapper/Analytics/*' - 'app/PaymentDrivers/Authorize/*' - 'app/Utils/Traits/*' - - 'resources/views/*' universalObjectCratesClasses: - App\DataMapper\Tax\RuleInterface - App\DataMapper\FeesAndLimits