| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Services;
- use App\Models\DeviceToken;
- use Illuminate\Support\Facades\Auth;
- class DeviceTokenService
- {
- public function register(array $data): DeviceToken
- {
- return DeviceToken::updateOrCreate(
- ['token' => $data['token']],
- [
- 'user_id' => Auth::id(),
- 'platform' => $data['platform'],
- 'app_type' => $data['app_type'],
- 'active' => true,
- ]
- );
- }
- public function remove(string $token): void
- {
- DeviceToken::where('token', $token)
- ->where('user_id', Auth::id())
- ->update(['active' => false]);
- }
- }
|