Advertisement
Guest User

Untitled

a guest
Aug 27th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. class UpdateTournamentCurrentSeason
  2. {
  3.     /**
  4.      * @param Tournament $tournament
  5.      * @return bool
  6.      * @throws \Throwable
  7.      */
  8.     public function __invoke(Tournament $tournament)
  9.     {
  10.         DB::beginTransaction();
  11.  
  12.         try {
  13.             $this->setTournament($tournament);
  14.             $this->parseInfo();
  15.  
  16.             if ($this->oldSeasonId != $this->newSeasonId) {
  17.                 $newTeams = $this->updateTeams();
  18.                 if ($newTeams) {
  19.                     $this->dispatchMatches();
  20.                     DB::commit();
  21.                     return true;
  22.                 }
  23.             }
  24.         } catch (\Exception $exception) {
  25.             DB::rollBack();
  26.             throw $exception;
  27.  
  28.         } catch (\Throwable $throwable) {
  29.             DB::rollBack();
  30.             throw $throwable;
  31.         }
  32.  
  33.        
  34.         // тут долно быть DB::rollBack();
  35.         return false;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement