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

58 lines
2.3 KiB
PHP
Raw Normal View History

2024-03-28 14:52:40 +05:30
<?php
namespace App\Http\Resources;
use App\Models\Product;
2024-04-12 15:07:34 +05:30
use App\Models\ProductImage;
2024-03-28 14:52:40 +05:30
use Illuminate\Http\Resources\Json\JsonResource;
class FractionalRealEstateResource 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,
2024-04-12 15:07:34 +05:30
'products_id' => $this->products_id,
'product_images' => $imagePaths,
2024-04-30 11:02:34 +05:30
'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,
2024-04-12 15:07:34 +05:30
'companies_id' => $this->companies_id,
'slug' => $this->slug,
'property_name_and_location' => $this->property_name_and_location,
'property_description' => $this->property_description,
'property_grade' => $this->property_grade,
'asset_type' => $this->asset_type,
'tenant' => $this->tenant,
'deal_size_in_crore' => $this->deal_size_in_crore,
'coupon_rate_on_ccd' => $this->coupon_rate_on_ccd,
'rental_escalation' => $this->rental_escalation,
'capital_appreciation' => $this->capital_appreciation,
'expected_irr' => $this->expected_irr,
'cagr' => $this->cagr,
'minimum_investment' => $this->minimum_investment,
'minimum_investment_lockin' => $this->minimum_investment_lockin,
'tenant_lease_term' => $this->tenant_lease_term,
'tenant_lock_in' => $this->tenant_lock_in,
'tenant_security_deposit' => $this->tenant_security_deposit,
'annual_management_fee' => $this->annual_management_fee,
'performance_fees' => $this->performance_fees,
'hurdle_rate' => $this->hurdle_rate,
2024-03-28 14:52:40 +05:30
];
}
}