migrate to gtea from bistbucket
This commit is contained in:
39
public/restaurant/app/Http/Controllers/WebsiteController.php
Normal file
39
public/restaurant/app/Http/Controllers/WebsiteController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\Firebase\FirebaseService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class WebsiteController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('welcome');
|
||||
}
|
||||
|
||||
public function saveFcmToken(Request $request)
|
||||
{
|
||||
$request->validate(['token' => 'required|string']);
|
||||
$user = auth()->user();
|
||||
$user->fcm_token = $request->token;
|
||||
$user->save();
|
||||
|
||||
return response()->json(['message' => 'FCM token saved']);
|
||||
}
|
||||
|
||||
public function sentNotification(FirebaseService $firebase)
|
||||
{
|
||||
$token = auth()->user?->fcm_token;
|
||||
if ($token) {
|
||||
$firebase->sendNotification(
|
||||
$token,
|
||||
'A Push notification',
|
||||
'Check the latest reply on your push notification.',
|
||||
);
|
||||
}
|
||||
|
||||
// Logic to send notification using Firebase
|
||||
return response()->json(['message' => 'Notification sent']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user