'datetime:Y-m-d', ]; protected $hidden = ['tables_id', 'total_views', 'created_by', 'modified_by', 'updated_at', 'deleted_at']; protected $fillable = ['tables_id', 'description', 'categories_id', 'total_views', 'status', 'top_pick', 'created_by', 'modified_by', 'presentation', 'fact_sheet', 'type', 'profit_sharing', 'upfront_rate', 'trail_rate', 'gst', 'tds', 'end_of_trail', 'channel_partner_aggrement']; // public function companies(){ // return $this->belongsTo(Company::class,'id','companies_id'); // } public function fractional_real_estate() { return $this->belongsTo(FractionalRealEstate::class, 'id', 'products_id'); } public function bonds() { return $this->belongsTo(Bonds::class, 'id', 'products_id'); } public function categorys() { return $this->belongsTo(Category::class,'categories_id', 'id'); } public function funds() { return $this->belongsTo(Fund::class, 'id', 'products_id'); } public function exchanges() { return $this->belongsTo(StockFundsRealEstateExchange::class, 'id', 'products_id'); } public function realEstates() { return $this->belongsTo(RealEstate::class, 'id', 'products_id'); } public function indianFinancialAssets() { return $this->belongsTo(IndianFinancialAssets::class, 'id', 'products_id'); } public function peerToPeers() { return $this->belongsTo(PeerToPeerLending::class, 'id', 'products_id'); } public function highYieldFinances() { return $this->belongsTo(HighYieldFinance::class, 'id', 'products_id'); } public function securitizedDebtInstruments() { return $this->belongsTo(SecuritizedDebtInstrument::class, 'id', 'products_id'); } public function cleanAndGreenAssets() { return $this->belongsTo(CleanAndGreenAsset::class, 'id', 'products_id'); } public function leaseBasedFinancing() { return $this->belongsTo(LeaseBasedFinancing::class, 'id', 'products_id'); } public function invoiceDiscounting() { return $this->belongsTo(InvoiceDiscounting::class, 'id', 'products_id'); } public function alternativeInvestmentFund() { return $this->belongsTo(AlternativeInvestmentFund::class, 'id', 'products_id'); } public function ventureDebt() { return $this->belongsTo(VentureDebt::class, 'id', 'products_id'); } public function realEstate() { return $this->belongsTo(RealEstate::class, 'id', 'products_id'); } public function category() { return $this->hasOne(Category::class, 'id', 'categories_id'); } public function scopeFractionalRealEstate($query) { return $query->where('tables_id', 1); } public function scopeBonds($query) { return $query->where('tables_id', 2); } public function scopeFunds($query) { return $query->where('tables_id', 3); } public function scopeExchanges($query) { return $query->where('tables_id', 4); } public function scopeRealEstates($query) { return $query->where('tables_id', 5); } public function scopeIndianFinancialAssets($query) { return $query->where('tables_id', 6); } public function scopePeerToPeers($query) { return $query->where('tables_id', 7); } public function scopeSecuritizedDebtInstruments($query) { return $query->where('tables_id', 8); } public function scopeHighYieldFinances($query) { return $query->where('tables_id', 9); } public function scopeCleanAndGreenAssets($query) { return $query->where('tables_id', 10); } public function scopeLeaseBasedFinancing($query) { return $query->where('tables_id', 11); } public function scopeInvoiceDiscounting($query) { return $query->where('tables_id', 13); } public function scopeAlternativeInvestmentFund($query) { return $query->where('tables_id', 12); } public function scopeVentureCapitalFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 28]); } public function scopePrivateCreditFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 41]); } public function scopeGlobalPrivateCreditFund($query) { return $query->where('categories_id', 42); } public function scopeInfrastructureFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 29]); } public function scopeAngelFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 30]); } public function scopePrivateEquityFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 31]); } public function scopeDebtFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 32]); } public function scopePrivateRealEstateFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 33]); } public function scopeFundForDistressedAsset($query) { return $query->where(['tables_id' => 12, 'categories_id' => 38]); } public function scopeHedgeFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 34]); } public function scopelongOnlyEquityFund($query) { return $query->where(['tables_id' => 12, 'categories_id' => 40]); } public function scopePipe($query) { return $query->where(['tables_id' => 12, 'categories_id' => 35]); } public function scopeVentureDebt($query) { return $query->where('tables_id', 14); } public function scopeSovereignGovernmentBond($query) { return $query->where(['categories_id' => Category::SovereignGovernmentBondId, 'tables_id' => 2, 'status' => true]); } public function scopeInvestmentGradeBond($query) { return $query->where(['categories_id' => Category::CorporateBondInvestmentGradeId, 'tables_id' => 2, 'status' => true]); } public function scopeHighYieldBond($query) { return $query->where(['categories_id' => Category::CorporateBondHighYieldId, 'tables_id' => 2, 'status' => true]); } public function scopeMutualFund($query) { return $query->where(['categories_id' => Category::GlobalMutualFundId, 'tables_id' => 3, 'status' => true]); } public function scopeGlobalVentureCapitalFund($query) { return $query->where(['categories_id' => Category::GlobalVentureCapitalFundId, 'tables_id' => 3, 'status' => true]); } public function scopeGlobalPrivateCreditFunds($query) { return $query->where(['categories_id' => Category::GlobalPrivateCreditFundId, 'tables_id' => 3, 'status' => true]); } public function scopeGlobalPrivateEquityFund($query) { return $query->where(['categories_id' => Category::GlobalPrivateEquityFundId, 'tables_id' => 3, 'status' => true]); } public function scopePrivateEquityFunds($query) { return $query->where(['categories_id' => Category::PrivateEquityFundId, 'tables_id' => 3, 'status' => true]); } public function scopeGlobalHedgeFund($query) { return $query->where(['categories_id' => Category::GlobalHedgeFundId, 'tables_id' => 3, 'status' => true]); } public function scopeEquities($query) { return $query->where(['categories_id' => Category::EquitiesId, 'tables_id' => 4, 'status' => true]); } public function scopeExchangeTradedFund($query) { return $query->where(['categories_id' => Category::ExchangeTradedFundsId, 'tables_id' => 4, 'status' => true]); } public function scopeReits($query) { return $query->where(['categories_id' => Category::RealEstateInvestmentTrustsId, 'tables_id' => 4, 'status' => true]); } public function scopeIndianIndustrialRealEstate($query) { return $query->where(['categories_id' => Category::IndianIndustrialRealEstateID, 'tables_id' => 5]); } public function scopeIndianCommercialRealEstate($query) { return $query->where(['categories_id' => Category::IndianCommercialRealEstateID, 'tables_id' => 5]); } public function scopeIndianResidentialRealEstate($query) { return $query->where(['categories_id' => Category::IndianResidentialRealEstateID, 'tables_id' => 5]); } public function scopeGlobalIndustrialRealEstate($query) { return $query->where(['categories_id' => Category::GlobalIndustrialRealEstateID, 'tables_id' => 5]); } public function scopeGlobalCommercialRealEstate($query) { return $query->where(['categories_id' => Category::GlobalCommercialRealEstateID, 'tables_id' => 5]); } public function scopeGlobalResidentialRealEstate($query) { return $query->where(['categories_id' => Category::GlobalResidentialRealEstateID, 'tables_id' => 5]); } public function scopeActive($query) { return $query->where('status', true); } public function scopeOpen($query) { return $query->where('type', 'Open'); } public function scopeFullyFunded($query) { return $query->where('type', 'Fully Funded'); } public function scopeResale($query) { return $query->where('type', 'Resale'); } public function getCompanyLogoAttribute($value) { if ($value) return imagePath('public/uploads/manufactures_company/logo/') . $value; } public function getPropertyImageAttribute($value) { if ($value) return imagePath('public/uploads/fractional_real_estate/property_image/') . $value; } public function getFileNameAttribute($value) { if ($value) return imagePath('public/uploads/real_estate/photos/') . $value; } public function product_images() { return $this->hasMany(ProductImage::class,'product_xid','id'); } // public function scopeGetAllDetails($query) // { // return $query->select(\DB::raw('products.id,coalesce(sdi.product_name, p2p.scheme, fre.property_name_and_location,id.company_name,aif.fund_name,caga.project_name,hyf.security_name,lbf.company,sdi.product_name,vd.company_name,bd.issuer,fd.fund_name,exchange.name,re.property_name) as product_name'), 'categories.category_name', 'top_pick', 'fre.property_image', 'company_logo', 'file_name') // ->leftJoin('securitized_debt_instruments as sdi', 'products.id', 'sdi.products_id') // ->leftJoin('fractional_real_estates as fre', 'products.id', 'fre.products_id') // ->leftJoin('peer_to_peer_lendings as p2p', 'products.id', 'p2p.products_id') // ->leftJoin('invoice_discountings as id', 'products.id', 'id.products_id') // ->leftJoin('alternative_investment_funds as aif', 'products.id', 'aif.products_id') // ->leftJoin('clean_and_green_assets as caga', 'products.id', 'caga.products_id') // ->leftJoin('high_yield_finances as hyf', 'products.id', 'hyf.products_id') // ->leftJoin('lease_based_financings as lbf', 'products.id', 'lbf.products_id') // ->leftJoin('venture_debts as vd', 'products.id', 'vd.products_id') // ->leftJoin('bonds as bd', 'products.id', 'bd.products_id') // ->leftJoin('funds as fd', 'products.id', 'fd.products_id') // ->leftJoin('stock_funds_real_estate_exchanges as exchange', 'products.id', 'exchange.products_id') // ->leftJoin('real_estates as re', 'products.id', 're.products_id') // ->leftJoin('companies', 'aif.companies_id', 'companies.id') // // ->leftjoin('product_photo_documents as ppd','re.id','ppd.real_estates_id') // ->leftJoin('product_photo_documents as ppd', function ($query) { // $query->on('re.id', 'ppd.real_estates_id') // ->where('ppd.type', 0); // }) // ->join('categories', 'products.categories_id', 'categories.id'); // } public function scopeGetAllDetails($query) { $equitiesStockExchangeRealEstateRoute = 'https://jerichoalternatives.in/api/equities-stock-real-estate-single-data/'; $products = $query->select(\DB::raw('products.id,products.description,coalesce(fre.property_name_and_location,aif.fund_name,bd.issuer,fd.fund_name,exchange.name,re.property_name) as product_name'), 'products.categories_id as categories_id', 'categories.category_name', 'top_pick', 'fre.property_image', 'company_logo', 'file_name', \DB::raw('coalesce(fre.geographic_focus,aif.geographic_focus,bd.geographic_focus,fd.geographic_focus,exchange.geographic_focus,re.geographic_focus) as geographic_focus'), \DB::raw('coalesce(fre.minimum_investment,aif.minimum_investment,bd.minimum_investment,fd.minimum_investment,re.total_price) as minimum_investment'), \DB::raw('coalesce(fre.slug,aif.slug,bd.slug,fd.slug,re.slug,exchange.slug) as slug'), // \DB::raw('coalesce(fre.property_description,aif.description,bd.about_issuer,fd.fund_description,exchange.about,re.remarks) as description') // \DB::raw('coalesce(products.description) as description') // 'products.description' ) ->leftJoin('fractional_real_estates as fre', 'products.id', 'fre.products_id') ->leftJoin('alternative_investment_funds as aif', 'products.id', 'aif.products_id') ->leftJoin('bonds as bd', 'products.id', 'bd.products_id') ->leftJoin('funds as fd', 'products.id', 'fd.products_id') ->leftJoin('stock_funds_real_estate_exchanges as exchange', 'products.id', 'exchange.products_id') ->leftJoin('real_estates as re', 'products.id', 're.products_id') ->leftJoin('companies', 'aif.companies_id', 'companies.id') ->leftJoin('product_photo_documents as ppd', function ($query) { $query->on('re.id', 'ppd.real_estates_id') ->where('ppd.type', 0); }) ->join('categories', 'products.categories_id', 'categories.id'); // ->addSelect(\DB::raw("(CASE // WHEN categories_id = '14' THEN '$equitiesStockExchangeRealEstateRoute' // WHEN categories_id = '12' THEN '123' // ELSE '456' // END) AS route")); // $categoriesId = $products->pluck('categories_id'); // $no = 1; // foreach ($products as $product) { // if ($no == 1) { // $product->addSelect(\DB::raw("'123' as route")); // } else { // $product->addSelect(\DB::raw("'456' as route")); // } // $no++; // } // $categoriesId->each(function ($category) use ($products) { // if($category == 14){ // $products->addSelect(\DB::raw("'123' as route")); // }else{ // $products->addSelect(\DB::raw("'46' as route")); // } // }); // foreach($products as $product){ // $product->addSelect(\DB::raw("'123' as route")); // } // $users = User::select("*", // \DB::raw('(CASE // WHEN users.status = "0" THEN "User" // WHEN users.status = "1" THEN "Admin" // ELSE "SuperAdmin" // END) AS status_lable')) // ->get(); // ->addSelect(\DB::raw("'123' as route")); return $products; } // const path = 'https://jerichoalternatives.in/fractional-real-estate/persantaion_file/'; // const path = 'https://jerichoalternatives.in/product/file/'; public function getPresentationAttribute($value) { if ($value) return imagePath('fractional-real-estate/persantaion_file/') . $value; } public function getFactSheetAttribute($value) { if ($value) return imagePath('fractional-real-estate/persantaion_file/') . $value; } }