category = $category; $this->columns = $columns; } public function collection() { $products_detail = MonthlyUpdateMaster::with('investor')->whereIn('categories',$this->category)->where('holding_status','Holding')->get(); $return_data = []; $data = collect(); $products_detail->each(function ($value) use ($data){ // dd($value); $return_data['name'] = $value->investor->name; $return_data['email'] = $value->investor->email; $return_data['custom_id'] = $value->custom_id; $return_data['product_name'] = $value->product_name; $return_data['product_category'] = $value->product_category; // if(AlternativeInvestmentFund::where('id',$value->products_id)->exists()) // { // $aid_data = Product::with('alternativeInvestmentFund','category')->where('id',$value->products_id)->first(); // $return_data['product_name'] = $aid_data->alternativeInvestmentFund->fund_name; // $return_data['product_category'] = $aid_data->category->category_name; // } // if(FractionalRealEstate::where('id',$value->products_id)->exists()) // { // $aid_data = Product::with('fractional_real_estate','category')->where('id',$value->products_id)->first(); // $return_data['product_name'] = $aid_data->fractional_real_estate->property_name_and_location; // $return_data['product_category'] = $aid_data->category->category_name; // } $data->push($return_data); }); // dd($data); return $data; } public function headings(): array { return $this->columns; } }