Skip to content

Commit

Permalink
Merge pull request #5 from rgasch/dev
Browse files Browse the repository at this point in the history
Fixed missing 'use' statement + better log handling for 'strict' issues.
  • Loading branch information
rgasch authored Nov 19, 2022
2 parents 3a6be9d + 8ad7cb3 commit e4cb60a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions InstallLaravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ function patchAppServiceProviderForStrictMode(string $color, string $noColor): v
$line = $fileLines[$i];
$output[] = $line;
if (!$firstUse && strpos($line, 'use ') === 0) {
$output[] = 'use Illuminate\Database\Connection';
$output[] = 'use Illuminate\Database\Eloquent\Model;';
$output[] = 'use Illuminate\Contracts\Http\Kernel as HttpKernel;';
$output[] = 'use Illuminate\Contracts\Console\Kernel as ConsoleKernel;';
Expand All @@ -546,13 +547,13 @@ function patchAppServiceProviderForStrictMode(string $color, string $noColor): v
if (\$this->app->isProduction()) {
Model::handleLazyLoadingViolationUsing(function (\$model, \$relation) {
\$class = get_class(\$model);
info(\"Attempted to lazy load [{\$relation}] on model [{\$class}].\");
Log::warning(\"Attempted to lazy load [{\$relation}] on model [{\$class}].\");
});
}
// Log queries which run for more than 1 second
DB::whenQueryingForLongerThan(1000, function (Connection \$connection) {
Log::warning(\"Database queries exceeded 2 seconds on {\$connection->getName()}\");
Log::warning(\"Database queries exceeded 1 second on {\$connection->getName()}\");
});
// Log slow Commands (5 seconds) or Requests (1 second)
Expand Down

0 comments on commit e4cb60a

Please sign in to comment.