Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| LogoutService | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| execute | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\Login\Services; |
| 4 | |
| 5 | use Illuminate\Http\Request; |
| 6 | |
| 7 | use App\Models\User; |
| 8 | |
| 9 | use Domain\User\Services\RemoveUserExpoTokenService; |
| 10 | use Domain\Login\DTOs\LogoutDTO; |
| 11 | use Illuminate\Support\Facades\Cache; |
| 12 | |
| 13 | readonly class LogoutService |
| 14 | { |
| 15 | /** |
| 16 | * @param User $user |
| 17 | * @param LogoutDTO $loginDTO |
| 18 | * @return void |
| 19 | */ |
| 20 | public static function execute(User $user, LogoutDTO $loginDTO): void |
| 21 | { |
| 22 | $tokenIds = $user->tokens()->pluck('id')->all(); |
| 23 | |
| 24 | foreach ($tokenIds as $tokenId) { |
| 25 | Cache::forget("erp_password_{$tokenId}"); |
| 26 | } |
| 27 | |
| 28 | $user->tokens()->delete(); |
| 29 | |
| 30 | (new RemoveUserExpoTokenService($user, $user, $loginDTO->expo_token))->remove(); |
| 31 | } |
| 32 | } |