mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-21 05:23:58 +00:00
66 lines
2.1 KiB
PHP
66 lines
2.1 KiB
PHP
<?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
|
|
];
|
|
}
|
|
}
|