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

79 lines
3.6 KiB
PHP
Raw Normal View History

2024-04-04 19:47:22 +05:30
<?php
namespace App\Http\Resources;
2024-06-04 18:42:41 +05:30
use App\Models\Category;
2024-04-04 19:47:22 +05:30
use App\Models\Product;
2024-04-12 12:20:39 +05:30
use App\Models\ProductImage;
2024-04-04 19:47:22 +05:30
use Illuminate\Http\Resources\Json\JsonResource;
2024-04-12 15:28:00 +05:30
// use App\Models\ProductImage;
2024-04-04 19:47:22 +05:30
class LongOnlyEquityResource 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-06-04 18:42:41 +05:30
$category = Product::with('categorys')->where('id',$this->products_id)->first();
2024-04-04 19:47:22 +05:30
return [
'id' => $this->id,
'products_id' => $this->products_id,
2024-04-12 15:07:34 +05:30
'product_images' => $imagePaths,
2024-06-04 18:42:41 +05:30
'category_name' => $category->categorys->category_name,
2024-04-29 19:19:42 +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-04 19:47:22 +05:30
'fund_name' => $this->fund_name,
'slug' => $this->slug,
'registration_number' => $this->registration_number,
'fund_category' => $this->fund_category,
'fund_structure' => $this->fund_structure,
'fund_strategy' => $this->fund_strategy,
'fund_domicile' => $this->fund_domicile,
'fund_manager_name' => $this->fund_manager_name,
'website_of_the_fund' => $this->website_of_the_fund,
'fund_manager_experience' => $this->fund_manager_experience,
'sponsor' => $this->sponsor,
'manager' => $this->manager,
'trustee' => $this->trustee,
'auditor' => $this->auditor,
'valuer_tax_advisor' => $this->valuer_tax_advisor,
'credit_rating' => $this->credit_rating,
'open_date' => $this->open_date,
'first_close_date' => $this->first_close_date,
'final_close_date' => $this->final_close_date,
'tenure_from_final_date' => $this->tenure_from_final_date,
'commitment_period' => $this->commitment_period,
'native_currency' => $this->native_currency,
'target_corpus' => $this->target_corpus,
'investment_manager_contribution' => $this->investment_manager_contribution,
'minimum_capital_commitment' => $this->minimum_capital_commitment,
'intial_drawdown' => $this->intial_drawdown,
'target_irr' => $this->target_irr,
'accepting_overseas_investment' => $this->accepting_overseas_investment,
'return_on_investment' => $this->return_on_investment,
'valuation_per_sector' => $this->valuation_per_sector,
'management_fees_and_carry' => $this->management_fees_and_carry,
'hurdle_rate' => $this->hurdle_rate,
'other_expenses' => $this->other_expenses,
'focused_funds' => $this->focused_funds,
'trading_strategy' => $this->trading_strategy,
'involved_in_short_selling' => $this->involved_in_short_selling,
'minimum_investment' => $this->minimum_investment,
2024-04-12 12:20:39 +05:30
'company' => $this->companies,
2024-04-15 13:43:51 +05:30
// 'product_images' => ProductImage::where('product_xid',$this->products_id)->get(),
2024-04-04 19:47:22 +05:30
];
}
}