Skip to content

Commit

Permalink
Added middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
rickgoemans committed May 22, 2023
1 parent 58837f5 commit e3c4b79
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Middleware/MigrateUserSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Rickgoemans\LaravelUserSettings\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Rickgoemans\LaravelUserSettings\Services\UserSettingService;
use Symfony\Component\HttpFoundation\Response;

class MigrateUserSettings
{
/** @param Closure(Request): (Response) $next */
public function handle(Request $request, Closure $next): Response
{
if (Auth::user()) {
/** @var UserSettingService $service */
$service = app(UserSettingService::class);

$service->migrate();
}

return $next($request);
}
}

0 comments on commit e3c4b79

Please sign in to comment.