/**
  * get the references of all transaction except transactionId
  * @return array
  */
 public function getTransactionReferencesExcept($activityId, $transactionId)
 {
     $transactions = $this->transaction->where(function ($query) use($activityId, $transactionId) {
         $query->where('id', '<>', $transactionId);
         $query->where('activity_id', '=', $activityId);
     })->get();
     $references = [];
     foreach ($transactions as $transactionRow) {
         $references[$transactionRow->transaction['reference']] = $transactionRow->id;
     }
     return $references;
 }
 /**
  * return activity data with results and transactions
  * @param int $id
  */
 private function getActivityData($id)
 {
     $activityData = Activity::find($id);
     if ($activityData) {
         $activityData = $activityData->toArray();
         $reportingOrg = Organization::find($activityData['organization_id'])->reporting_org;
         $results = ActivityResult::where('activity_id', $id)->get()->toArray();
         $transactions = Transaction::where('activity_id', $id)->get()->toArray();
         $documentLinks = ActivityDocumentLink::where('activity_id', $id)->get()->toArray();
         $activityData['results'] = $results;
         $activityData['transactions'] = $transactions;
         $activityData['document_link'] = $documentLinks;
         $activityData['reporting_organization'] = $reportingOrg;
     }
     return $activityData;
 }
예제 #3
0
 /**
  * Delete specific activity transaction
  * @param TransactionModel $transaction
  * @return bool|null
  * @throws \Exception
  */
 public function deleteTransaction(TransactionModel $transaction)
 {
     return $transaction->delete();
 }
예제 #4
0
 /**
  * get all transactions of an activity
  * @param $activityId
  * @return mixed
  */
 public function getActivityTransactions($activityId)
 {
     return $this->transaction->where('activity_id', $activityId)->get();
 }