I have upgraded a Lravel 10 app to the latest Laravel 12.36.1.
On the Laravel 10 app I have an Ajax call in the backoffice to put the project down or up that calls a method setMaintenanceMode(string $mode) like the following:
use Artisan;
use Str;
class MaintenanceService {
public function setMaintenanceMode(string $mode): array
{
if($mode == 'down') {
Artisan::call('down', [
'--render' => 'errors.maintenance',
'--secret' => config('app.maintenance.secret'),
'--retry' => config('app.maintenance.app_downtime_seconds', 600),
]);
session()->put('maintenance_mode', true);
}
if($mode == 'up') {
Artisan::call('up');
session()->forget('maintenance_mode');
}
$mode_new = $mode == 'down' ? 'up' : 'down';
$data = [
'command' => $mode,
'command_name' => ucfirst($mode),
'command_name_slug' => Str::slug($mode),
'last_run' => now(),
'run_mode' => 'manual',
'run_result' => 1,
];
return [
'message' => session()->has('maintenance_mode') ? 'Site is down' : 'Site is up',
'mode' => $mode,
'new_mode' => $mode_new,
'class' => session()->has('maintenance_mode') ? 'danger' : 'success',
];
}
}
Even in Maintenace mode, the down file that is set by Laravel can de removed when calling the method setMaintenanceMode(string $mode) being the value passed $mode="up".
On Laravel 10 it works, yet on Laravel 12 when using the same method as above and trying to put the project up by passing the value as $mode="up" it throws a 503 error and the the Ajax call returns it as 503.
My question is: is there a way to override the maintenance mode when calling Artisan::call() while in maintenance mode and get a 200 ok status?