Я получаю сообщение об ошибке «Нет результатов запроса для модели [App \ Posts].», Но модель возвращает результат в основном.Я пытаюсь использовать кнопку pusher для отправки события о новом сообщении.
$post = \App\Posts::find(1);
if($post) {
event(new \App\Events\NewPost($post));
}
Событие:
class NewPost implements ShouldBroadcastNow
{
use Dispatchable, InteractsWithSockets, SerializesModels;
private $post;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($post)
{
$this->post = $post;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('messages');
}
public function broadcastWith() {
return [
'id' => $this->post->id
];
}
}