Skip to content

Commit

Permalink
Merge branch 'main' into feature/landing-page
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Aug 10, 2024
2 parents e98aef6 + 0df210e commit edd3fea
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
48 changes: 48 additions & 0 deletions app/Maintenance/EnvMaintenanceMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace App\Maintenance;

use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Foundation\MaintenanceMode;

class EnvMaintenanceMode implements MaintenanceMode
{
public function __construct(protected Application $app) {}

/**
* Take the application down for maintenance.
*
* @param array $payload
* @return void
*/
public function activate(array $payload): void {
//
}

/**
* Take the application out of maintenance.
*
* @return void
*/
public function deactivate(): void {
//
}

/**
* Determine if the application is currently down for maintenance.
*
* @return bool
*/
public function active(): bool {
return $this->app->environment(['maintenance']);
}

/**
* Get the data array which was provided when the application was placed into maintenance.
*
* @return array
*/
public function data(): array {
return [];
}
}
17 changes: 16 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

namespace App\Providers;

use App\Maintenance\EnvMaintenanceMode;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Foundation\MaintenanceModeManager;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

Expand All @@ -12,7 +16,18 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
//
$this->app->extend(
MaintenanceModeManager::class,
function (MaintenanceModeManager $manager) {
$manager->extend('env', function (Container $container) {
return new EnvMaintenanceMode(
$container->make(Application::class)
);
});

return $manager;
}
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
| Supported drivers: "file", "cache", "env"
|
*/

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
dockerfile: ./dockerfiles/Dockerfile.website
target: deploy-nocache
args:
- LARAVEL_ENV=local
- LARAVEL_ENV=${APP_ENV:-local}
- LARAVEL_ENV_FILE=.env
ports:
- '80:80'
Expand Down

0 comments on commit edd3fea

Please sign in to comment.