mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 12:33:56 +00:00
38 lines
973 B
PHP
38 lines
973 B
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Classes\ValueObjects\Constants\TransactionType;
|
|
use App\Models\Wallet;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
class MappableTransactionResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$reference = null;
|
|
if($this->type === TransactionType::TOP_UP) {
|
|
$reference = $this->owner->owner->reference;
|
|
}
|
|
|
|
if($this->type === TransactionType::PAYMENT && $this->owner !== Wallet::class){
|
|
$reference = $this->owner->marking;
|
|
}
|
|
|
|
return [
|
|
'status' => 'success',
|
|
'system' => 'EXCHANGE',
|
|
'type' => $this->type,
|
|
'owner_type' => $this->owner_type,
|
|
'owner_id'=> $this->id,
|
|
'owner_reference'=> $reference,
|
|
];
|
|
}
|
|
}
|