0👍
- You need to pass the
$user
and$o
variables into your broadcast route callback and wrap the parameter definition in curly braces:
Broadcast::channel('osc{o}', function($user, Order $o) { ... });
- When you don’t want echo to prefix the entire event namespace to your event, you need to prefix your event name (on the front-end only) with a
.
:
.listen('.oscEvent', (e) ...
- In your
oscEvent
class, you should type-hint the $order parameter in the constructor:
public function __construct(Order $order) { ... }
- Without seeing the Echo initialization, it’s hard to tell if you’ve configured it correctly for authentication. Did you add the csrf token to the page so echo could pick it up?
From the Laravel docs:
Laravel Echo will need access to the current session’s CSRF token. You should verify that your application’s head HTML element defines a meta tag containing the CSRF token:
<meta name="csrf-token" content="{{ csrf_token() }}">
- Make sure
Broadcast::routes();
is called in yourBroadcastServiceProvider::boot
method.
Hope this helps.
NOTE
I’m thinking you probably do want to prefix the entire namespace to your event, so you can probably ignore suggestion #2
- [Vuejs]-[Vue warn]: Error in render: "TypeError: Cannot read property 'type' of undefined"
- [Vuejs]-Vuejs use v-if with hash variable
0👍
It still does not work.
-
I modified channel callback
Broadcast::channel('osc{o}', function ($user,Order $o) { return (int) $user === (int) $o->user_id; });
-
I made type-hint Order class.
- I’m extending “layouts.app” template in my user and admin views.
- Yes, it is called.
I’m using laravel 5.6.
- [Vuejs]-Vuetify modifying inline edit data table content from method
- [Vuejs]-ELEMENT UI – How to increase the size of ICON?
Source:stackexchange.com