-
app/BulkActions/Banking/Reconciliations.php
Open in GitHubuse App\Abstracts\BulkAction; use App\Models\Banking\Reconciliation; use App\Models\Banking\Transaction; class Reconciliations extends BulkAction { // public function reconcile($request) { $reconciliations = $this->getSelectedRecords($request); foreach ($reconciliations as $reconciliation) { \DB::transaction(function () use ($reconciliation) { $reconciliation->reconciled = 1; $reconciliation->save(); Transaction::where('account_id', $reconciliation->account_id) ->isNotReconciled() ->whereBetween('paid_at', [$reconciliation->started_at, $reconciliation->ended_at])->each(function ($item) { $item->reconciled = 1; $item->save(); }); }); } } // }