mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-25 15:34:02 +00:00
fix and update the functionality and the ui for accounting automation
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Resources;
|
||||
|
||||
use App\Models\Booking;
|
||||
use App\Models\Group;
|
||||
use App\Models\Transaction;
|
||||
use App\Models\Wallet;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class BankStatementTransactionOwnerResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($request)
|
||||
{
|
||||
$reference = null;
|
||||
$referenceLink = null;
|
||||
if($this->system === 'EXCHANGE') {
|
||||
if($this->owner_type === Transaction::class){
|
||||
$transaction = Transaction::find($this->owner_id);
|
||||
|
||||
if($transaction->owner_type === Booking::class){
|
||||
$reference = $transaction->owner->marking;
|
||||
$referenceLink = route('booking.details', $transaction->owner->marking);
|
||||
}
|
||||
|
||||
if($transaction->owner_type === Wallet::class) {
|
||||
$reference = $transaction->owner->owner->reference;
|
||||
$referenceLink = route('wallet.details', $transaction->owner->owner->reference);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->owner_type === Group::class){
|
||||
$transaction = Group::find($this->owner_id);
|
||||
$reference = $transaction->reference;
|
||||
// $referenceLink = route('booking.details', $transaction->owner->marking);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->system === 'SHIPPING_PORTAL') {
|
||||
if($this->owner_type === Transaction::class){
|
||||
$transaction = Transaction::find($this->owner_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'type' => $this->type,
|
||||
'system' => $this->system,
|
||||
'owner_type' => $this->owner_type,
|
||||
'owner_id' => $this->owner_id,
|
||||
'reference_link' => $referenceLink,
|
||||
'reference' => $reference,
|
||||
'invoice_reference' => $this->invoice_reference,
|
||||
'receipt_reference' => $this->receipt_reference,
|
||||
'status' => $this->status
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user