Files
freeu-project/app/Http/Resources/LeaseBasedFinancingResource.php

50 lines
1.7 KiB
PHP
Raw Normal View History

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 LeaseBasedFinancingResource 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 [
'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
'company' => $this->company,
'slug' => $this->slug,
'asset_class' => $this->asset_class,
'underlying_asset' => $this->underlying_asset,
'sector' => $this->sector,
'mobility_platform' => $this->mobility_platform,
'total_deal_size' => $this->total_deal_size,
'minimum_investment' => $this->minimum_investment,
'tenure' => $this->tenure,
'payout_frequency' => $this->payout_frequency,
'pre_tax_return' => $this->pre_tax_return,
'minimum_investment_in_int' => $this->minimum_investment_in_int,
];
}
}