|
|
- <?php
-
- namespace App\Events;
-
- use Illuminate\Broadcasting\Channel;
- use Illuminate\Queue\SerializesModels;
- use Illuminate\Broadcasting\PrivateChannel;
- use Illuminate\Broadcasting\PresenceChannel;
- use Illuminate\Foundation\Events\Dispatchable;
- use Illuminate\Broadcasting\InteractsWithSockets;
- use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
-
- use App\Tweet;
-
- class NewTweetEvent implements ShouldBroadcast
- {
- use Dispatchable, InteractsWithSockets, SerializesModels;
-
- public $tweet_id;
- public $tweet_date;
- public $team_name;
- public $team_color;
- public $player_username;
- public $player_photo;
- public $text;
- public $photos;
- public $mission;
- public $mission_id;
-
- /**
- * Create a new event instance.
- *
- * @return void
- */
- public function __construct(Tweet $tweet)
- {
- $this->tweet_id = $tweet->id;
- $this->tweet_date = strtotime($tweet->tweet_date);
- $this->team_name = $tweet->team->name;
- $this->team_color = $tweet->team->color;
- $this->player_username = $tweet->player->twitter;
- $this->player_photo = $tweet->player->photo;
- $this->text = $tweet->text;
- $this->photos = json_decode($tweet->photo);
- $this->mission = $tweet->mission->hashtag;
- $this->mission_id = $tweet->mission_id;
- }
-
- /**
- * Get the channels the event should broadcast on.
- *
- * @return Channel|array
- */
- public function broadcastOn()
- {
- return ['tweet-queue'];
- }
- }
|