Total Complexity | 2 |
Total Lines | 17 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 0 |
1 | <?php |
||
9 | class OptimizeImages |
||
10 | { |
||
11 | public function handle($request, Closure $next) |
||
12 | { |
||
13 | $optimizerChain = app(OptimizerChain::class); |
||
14 | |||
15 | collect($request->allFiles())->each(function ($file) use ($optimizerChain) { |
||
16 | if (is_array($file)) { |
||
17 | collect($file)->each(function ($media) use ($optimizerChain) { |
||
18 | $optimizerChain->optimize($media->getPathname()); |
||
19 | }); |
||
20 | } else { |
||
21 | $optimizerChain->optimize($file->getPathname()); |
||
22 | } |
||
23 | }); |
||
24 | |||
25 | return $next($request); |
||
26 | } |
||
28 |