File: /var/www/staging.fixgini.com/app/Livewire/DeviceToken.php
<?php
namespace App\Livewire;
use App\Models\User;
use Livewire\Component;
use Illuminate\Support\Facades\Session;
class DeviceToken extends Component
{
protected $listeners = ['updateDeviceToken'];
public function updateDeviceToken($token)
{
// Get the authenticated user
$user = Session::get('user');
$user = User::find($user['id']);
// Update the device token
if ($user) {
$user->device_token = $token;
$user->save();
session()->flash('message', 'Device token updated successfully.');
}
}
public function render()
{
return view('livewire.device-token');
}
}