<?php namespace App\Http\Middleware; use Closure; class MinifyHtml { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function minifyHTML($htmlString) { $replace = [ '<!--(.*?)-->' => '', //remove comments "/<\?php/" => '<?php ', "/\n([\S])/" => '$1', "/\r/" => '', // remove carriage return "/\n/" => '', // remove new lines "/\t/" => '', // remove tab "/\s+/" => ' ', // remove spaces ]; } public function handle(Request $request, Closure $next) { $response = $next($request); $content = $response->getContent(); $output = $this->minifyHTML($content); $response->setContent($output); return $response; } }
i chciałbym użyć tego kodu w web routes:
Route::get('/admin/', 'Admin@showSetup')->name("admin-index");
jak dodać to do tego fragmentu? Przepraszam jeśli zbytnio się nie orientuję... uczę się Laravela, a co dopiero to w nim raczkuję... Strasznie dziwne to dla mnie... Myślałem że znając komendy
php artisan make:controller --LifeController
oraz
php artisan make:migration create_the_guys_with_she_cheats_me_table --table=guys_with_she_cheats_me
oraz model
php artisan make:model She
To mogę już wszystko w laravel, a jednak się myliłem

Dobra... już wiem... middleware samo się importuje w praniu
