| Total Complexity | 2 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class CopyClosingsToAttrs extends Command |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The name and signature of the console command. |
||
| 13 | * |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | protected $signature = 'closing:copy-to-attrs'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The console command description. |
||
| 20 | * |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $description = 'Copy the closings from their own table to the tontine attributes'; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Execute the console command. |
||
| 27 | * |
||
| 28 | * @return int |
||
| 29 | */ |
||
| 30 | public function handle() |
||
| 31 | { |
||
| 32 | DB::transaction(function() { |
||
| 33 | foreach(Closing::savings()->with('fund.tontine')->cursor() as $closing) |
||
| 34 | { |
||
| 35 | $tontine = $closing->fund->tontine; |
||
| 36 | $properties = $tontine->properties; |
||
| 37 | $properties['closings'][$closing->session_id][$closing->fund_id] = $closing->profit; |
||
| 38 | $tontine->saveProperties($properties); |
||
| 39 | } |
||
| 40 | }); |
||
| 41 | |||
| 42 | return Command::SUCCESS; |
||
| 43 | } |
||
| 45 |