|
|
- <?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 ? $tweet->team->name : null);
- $this->team_color = ($tweet->team ? $tweet->team->color : null);
- $this->player_username = ($tweet->player ? $tweet->player->twitter : null);
- $this->player_photo = ($tweet->player ? $tweet->player->photo : null);
- $this->text = $tweet->text;
- $this->photos = json_decode($tweet->photo);
- $this->mission = ($tweet->mission ? $tweet->mission->hashtag : null);
- $this->mission_id = $tweet->mission_id;
- }
-
- /**
- * Get the channels the event should broadcast on.
- *
- * @return Channel|array
- */
- public function broadcastOn()
- {
- return ['tweet-queue'];
- }
- }
|