Blame view

app/Queries/Predictor/PredictorProjector.php 667 Bytes
e77200db5   nologostudio.ru   Initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  <?php
  
  namespace FootyRoom\Queries\Predictor;
  
  use FootyRoom\Support\MongoClient;
  use FootyRoom\Core\Predictor\PredictionStakeRaised;
  
  class PredictorProjector
  {
      /**
       * @var \FootyRoom\Support\MongoClient
       */
      protected $mongo;
  
      public function __construct(MongoClient $mongo)
      {
          $this->mongo = $mongo;
      }
  
      public function whenPredictionStakeRaised(PredictionStakeRaised $event): void
      {
          $this->mongo->footyroom->selectCollection('predictor.players')->updateOne(
              ['userId' => $event->prediction->getUserId()],
              ['$inc' => ['stake' => $event->raise, 'locked' => $event->raise]]
          );
      }
  }