Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| EncourageSetup | |
100.00% |
6 / 6 |
|
100.00% |
2 / 2 |
5 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| handle | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Middleware; |
| 4 | |
| 5 | use App\Services\Setup\SetupWizard; |
| 6 | use Closure; |
| 7 | use Illuminate\Http\Request; |
| 8 | use Symfony\Component\HttpFoundation\Response; |
| 9 | |
| 10 | /** |
| 11 | * On the first visit to the dashboard, send an operator who can change |
| 12 | * settings to the setup guide. Once the guide is finished or skipped |
| 13 | * (setup.finished = true) this never fires again. |
| 14 | */ |
| 15 | class EncourageSetup |
| 16 | { |
| 17 | public function __construct(private SetupWizard $wizard) {} |
| 18 | |
| 19 | public function handle(Request $request, Closure $next): Response |
| 20 | { |
| 21 | if ( |
| 22 | $request->isMethod('GET') |
| 23 | && ! $this->wizard->finished() |
| 24 | && permissions()->allows('manage_settings') |
| 25 | ) { |
| 26 | return redirect()->route('admin.setup.index'); |
| 27 | } |
| 28 | |
| 29 | return $next($request); |
| 30 | } |
| 31 | } |