53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
use App\Models\Product;
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
use App\Models\ProductImage;
|
|
|
|
|
|
class SecuritizedDebtInstrumentResource extends JsonResource
|
|
{
|
|
/**
|
|
* Transform the resource into an array.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
*/
|
|
public function toArray($request)
|
|
{
|
|
$images = ProductImage::where('product_xid', $this->products_id)->get();
|
|
$imagePaths = [];
|
|
if (!empty($images)) {
|
|
foreach ($images as $imageItem) {
|
|
$path = asset('public/' . $imageItem['images']);
|
|
$imagePaths[] = $path;
|
|
}
|
|
|
|
}
|
|
return [
|
|
'id' => $this->id,
|
|
'products_id' => $this->products_id,
|
|
'product_images' => $imagePaths,
|
|
'presentation' => Product::find($this->products_id)->value('presentation'),
|
|
'fact_sheet' => Product::find($this->products_id)->value('fact_sheet'),
|
|
'slug' => $this->slug,
|
|
'product_name' => $this->product_name,
|
|
'total_deal_size' => $this->total_deal_size,
|
|
'minimum_investment' => $this->minimum_investment,
|
|
'credit_rating' => $this->credit_rating,
|
|
'deal_tenure' => $this->deal_tenure,
|
|
'target_irr' => $this->target_irr,
|
|
'target_multiple' => $this->target_multiple,
|
|
'payout_frequency' => $this->payout_frequency,
|
|
'principal_returned_in' => $this->principal_returned_in,
|
|
'average_annual_payback' => $this->average_annual_payback,
|
|
'security_enhancement' => $this->security_enhancement,
|
|
'listing_details' => $this->listing_details,
|
|
'minimum_investment_in_int' => $this->minimum_investment_in_int,
|
|
];
|
|
}
|
|
}
|