<?php
namespace App\Http\Middleware;
use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
use Closure;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\Encrypter as EncrypterContract;
use Illuminate\Cookie\CookieValuePrefix;
use Symfony\Component\HttpFoundation\Cookie;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class EncryptCookies extends Middleware
{
public function handle($request, Closure $next)
{
$response = parent::handle($request, $next);
dump('Encrypt!');
return $response;
}
}
"require": {
"php": "^8.1",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8"
},
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
Route::group([
'as' => 'basket.',
'prefix' => 'basket',
], function (){
Route::get('',[BasketController::class,'index'])->name('index');
Route::get('checkout',[BasketController::class,'checkout'])->name('checkout');
Route::post('add/{id}',[BasketController::class,'add'])->where('id','[0-9]+')->name('add');
Route::post('plus/{id}',[BasketController::class,'plus'])->where('id','[0-9]+')->name('plus');
Route::post('minus/{id}',[BasketController::class,'minus'])->where('id','[0-9]+')->name('minus');
Route::post('remove/{id}',[BasketController::class,'remove'])->where('id','[0-9]+')->name('remove');
Route::post('clear',[BasketController::class,'clear'])->name('clear');
});
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});