fix up group transactions bulk purchase orders

This commit is contained in:
omair saleh
2022-07-15 14:00:35 +08:00
parent ca4c3a0f1e
commit d75e3cb2bc
+1 -8
View File
@@ -21,13 +21,6 @@ class GroupResource extends JsonResource
*/
public function toArray($request)
{
dd($this->transactions()->whereHasMorph('owner', [Transaction::class], function($query){
return $query->whereHas('booking', function($query){
return $query->whereHas('transactions', function($query){
return $query->where('type', TransactionType::PURCHASE_ORDER)->where('status', '=', ApprovalStatus::APPROVED);
});
});
})->get());
return [
'id' => $this->id,
@@ -47,7 +40,7 @@ class GroupResource extends JsonResource
return $query->where('type', TransactionType::PURCHASE_ORDER)->where('status', '=', ApprovalStatus::APPROVED);
});
});
})->count(),
})->get()->pluck('owner.owner.marking'),
'documents' => [
'currency_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::CURRENCY_VENDOR_ORDER)->first()),
'purchase_order' => new DocumentResource($this->documents()->where('document_type', DocumentType::BULK_PURCHASE_ORDER)->first())