Files
freeu-project/app/Http/Resources/GlobalBondResource.php
Ritikesh yadav f08d2c3462 fixed api
2024-04-29 19:19:42 +05:30

53 lines
2.2 KiB
PHP

<?php
namespace App\Http\Resources;
use App\Models\Product;
use Illuminate\Http\Resources\Json\JsonResource;
class GlobalBondResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
*/
public function toArray($request)
{
// return parent::toArray($request);
return [
'id' => $this->id,
'products_id' => $this->products_id,
'presentation' => Product::find($this->products_id) ? Product::where('id',$this->products_id)->value('presentation') : null,
'fact_sheet' => Product::find($this->products_id) ? Product::where('id',$this->products_id)->value('fact_sheet') : null,
'slug' => $this->slug,
'issuer' => $this->issuer,
'type' => $this->type,
'bond_type' => $this->bond_type,
'about_issuer' => $this->about_issuer,
'industry' => $this->industry,
'country_of_risk' => $this->country_of_risk,
'country_of_incorporation' => $this->country_of_incorporation,
'isin' => $this->isin,
'bond_type_or_maturity_date' => $this->bond_type_or_maturity_date,
'call_date' => $this->call_date,
'coupon' => $this->coupon,
'indicative_yield_pa_mid' => $this->indicative_yield_pa_mid,
'indicative_price_us_mid' => $this->indicative_price_us_mid,
'minimum_investment' => $this->minimum_investment,
'construction_status' => $this->construction_status,
'yield_to_worst_pa_ask' => $this->yield_to_worst_pa_ask,
'yield_to_worst_pa_bid' => $this->yield_to_worst_pa_bid,
'price_ask' => $this->price_ask,
'price_bid' => $this->price_bid,
'accrued_interest' => $this->accrued_interest,
'yield_to_call' => $this->yield_to_call,
'duration' => $this->duration,
'amount_outstanding' => $this->amount_outstanding,
'collateral_type' => $this->collateral_type,
'credit_rating' => $this->credit_rating,
];
}
}