| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Spatie\LaravelIgnition\Support;
|
|
|
4 |
|
|
|
5 |
class RunnableSolutionsGuard
|
|
|
6 |
{
|
|
|
7 |
/**
|
|
|
8 |
* Check if runnable solutions are allowed based on the current
|
|
|
9 |
* environment and config.
|
|
|
10 |
*
|
|
|
11 |
* @return bool
|
|
|
12 |
*/
|
|
|
13 |
public static function check(): bool
|
|
|
14 |
{
|
|
|
15 |
if (! config('app.debug')) {
|
|
|
16 |
// Never run solutions in when debug mode is not enabled.
|
|
|
17 |
|
|
|
18 |
return false;
|
|
|
19 |
}
|
|
|
20 |
|
|
|
21 |
if (config('ignition.enable_runnable_solutions') !== null) {
|
|
|
22 |
// Allow enabling or disabling runnable solutions regardless of environment
|
|
|
23 |
// if the IGNITION_ENABLE_RUNNABLE_SOLUTIONS env var is explicitly set.
|
|
|
24 |
|
|
|
25 |
return config('ignition.enable_runnable_solutions');
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
if (! app()->environment('local') && ! app()->environment('development')) {
|
|
|
29 |
// Never run solutions on non-local environments. This avoids exposing
|
|
|
30 |
// applications that are somehow APP_ENV=production with APP_DEBUG=true.
|
|
|
31 |
|
|
|
32 |
return false;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
return config('app.debug');
|
|
|
36 |
}
|
|
|
37 |
}
|