2024-03-28 14:52:40 +05:30
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Resources;
|
|
|
|
|
|
|
|
|
|
use App\Models\Product;
|
|
|
|
|
use Illuminate\Http\Resources\Json\JsonResource;
|
|
|
|
|
|
2024-04-12 15:07:34 +05:30
|
|
|
use App\Models\ProductImage;
|
|
|
|
|
|
|
|
|
|
|
2024-03-28 14:52:40 +05:30
|
|
|
class HighYieldFinanceResource extends JsonResource
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Transform the resource into an array.
|
|
|
|
|
*
|
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
|
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
|
|
|
|
*/
|
|
|
|
|
public function toArray($request)
|
|
|
|
|
{
|
2024-04-12 15:07:34 +05:30
|
|
|
$images = ProductImage::where('product_xid', $this->products_id)->get();
|
|
|
|
|
$imagePaths = [];
|
|
|
|
|
if (!empty($images)) {
|
|
|
|
|
foreach ($images as $imageItem) {
|
|
|
|
|
$path = asset('public/' . $imageItem['images']);
|
|
|
|
|
$imagePaths[] = $path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2024-03-28 14:52:40 +05:30
|
|
|
// return parent::toArray($request);
|
|
|
|
|
return [
|
|
|
|
|
'id' => $this->id,
|
|
|
|
|
'products_id' => $this->products_id,
|
2024-04-12 15:07:34 +05:30
|
|
|
'product_images' => $imagePaths,
|
2024-04-30 11:02:34 +05:30
|
|
|
'presentation' => Product::where('id',$this->products_id)->value('presentation'),
|
|
|
|
|
'fact_sheet' => Product::where('id',$this->products_id)->value('fact_sheet'),
|
2024-03-28 14:52:40 +05:30
|
|
|
'slug' => $this->slug,
|
|
|
|
|
'security_name' => $this->security_name,
|
|
|
|
|
'security_type' => $this->security_type,
|
|
|
|
|
'isin' => $this->isin,
|
|
|
|
|
'issuer_company' => $this->issuer_company,
|
|
|
|
|
'issue_size' => $this->issue_size,
|
|
|
|
|
'issue_type' => $this->issue_type,
|
|
|
|
|
'listing_details' => $this->listing_details,
|
|
|
|
|
'rating_category' => $this->rating_category,
|
|
|
|
|
'minimum_investment' => $this->minimum_investment,
|
|
|
|
|
'coupon_rate' => $this->coupon_rate,
|
|
|
|
|
'yield_to_maturity' => $this->yield_to_maturity,
|
|
|
|
|
'interest_payment_frequency' => $this->interest_payment_frequency,
|
|
|
|
|
'allotment_date' => $this->allotment_date,
|
|
|
|
|
'maturity_date' => $this->maturity_date,
|
|
|
|
|
'minimum_investment_in_int' => $this->minimum_investment_in_int,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|