| 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_get($data, 'token')],
- [
- 'user_id' => Auth::id(),
- 'platform' => data_get($data, 'platform'),
- 'app_type' => data_get($data, 'app_type'),
- 'active' => true,
- ]
- );
- }
- public function remove(string $token): void
- {
- DeviceToken::where('token', $token)
- ->where('user_id', Auth::id())
- ->update(['active' => false]);
- }
- }
|