Files
freeu-project/app/Http/Resources/InvoiceDiscountingResource.php
2024-04-12 15:07:34 +05:30

55 lines
1.9 KiB
PHP

<?php
namespace App\Http\Resources;
use App\Models\Product;
use App\Models\ProductImage;
use Illuminate\Http\Resources\Json\JsonResource;
class InvoiceDiscountingResource 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'),
'company_name' => $this->company_name,
'slug' => $this->slug,
'sector' => $this->sector,
'about_company' => $this->about_company,
'key_performance_metrics' => $this->key_performance_metrics,
'minimum_investment' => $this->minimum_investment,
'total_deal_size' => $this->total_deal_size,
'tenure' => $this->tenure,
'pre_tax_irr' => $this->pre_tax_irr,
'coupon_rate' => $this->coupon_rate,
'vendor' => $this->vendor,
'recourse_on' => $this->recourse_on,
'settlement_date' => $this->settlement_date,
'payout_frequency' => $this->payout_frequency,
'payment_obligor' => $this->payment_obligor,
'security_structure' => $this->security_structure,
'minimum_investment_in_int' => $this->minimum_investment_in_int,
];
}
}