Laravel 推手 return 视图

Laravel Pusher return view

我使用推送器,但在调用事件时不会 return 视图。我有一个带有逻辑的模式,我需要在事件开始时显示它我在 google 中找不到关于它的答案也许这里可以帮助我。

如果需要更多详细信息,我可以展示所有方法,谢谢。

事件代码

<?php

namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class TriviaStatus implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets;

    public $question;
    public $answer_options;


    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($question, $answer_options)
    {
        $this->question  = $question;
        $this->answer_options  = $answer_options;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return ['trivia-status'];
    }

}

调用操作

public function SendQuestion(Request $request, $id)
    {

        $this->option->updateLeaderBoardshowAllResult(0);

        //Update All Question;
        $this->question->updateAll($request);

       
        //Update Question Byd ID
        $this->question->update($request, $id);


        event(new TriviaStatus($this->QuestionSentTime()['question'],$this->QuestionSentTime()['answer_options']));

        exit;


        return redirect('/admin/event');
    }

我想要return这个:

    return view('partials.question_modal', compact('question', 'answer_options'));

我的解决方案
活动代码:

public function broadcastWith()
    {
        $response = response()
            ->view('partials.question_modal', ['question' => $this->question, 'answer_options' => $this->answer_options], 200)
            ->header('Content-Type', 'application/json');

        return [$response->getContent()];
      
    }