Channel
This commit is contained in:
@@ -101,6 +101,13 @@ Route::get('filters', [FilterController::class, 'index']);
|
||||
// Global orders...
|
||||
Route::post('global-order', [GlobalOrderController::class, 'store']);
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::get('/chat/contacts', [ChatController::class, 'contacts']);
|
||||
Route::get('/chat/messages/{conversation}', [ChatController::class, 'messages']);
|
||||
Route::post('/chat/start', [ChatController::class, 'start']);
|
||||
Route::post('/chat/send', [ChatController::class, 'send']);
|
||||
});
|
||||
|
||||
Route::middleware(['auth:sanctum', 'banned'])->group(function () {
|
||||
// Profile...
|
||||
Route::get('profile', [ProfileController::class, 'index']);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -12,3 +13,10 @@ use Illuminate\Support\Facades\Broadcast;
|
||||
| used to check if an authenticated user can listen to the channel.
|
||||
|
|
||||
*/
|
||||
|
||||
Broadcast::channel('chat.{conversationId}', function ($user, $conversationId) {
|
||||
return DB::table('conversation_user')
|
||||
->where('conversation_id', $conversationId)
|
||||
->where('user_id', $user->id)
|
||||
->exists();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user