@php // dd($prod->cross_selling_products); $crossIds = []; foreach ($prod->cross_selling_products as $crProd) { $crossIds[] = $crProd->cross_selling_product_id; } $countCsProds = 0; $term = str_slug($prod->name, ' '); // check if the product's childcategory is in `cs_category_relations` table if (!empty($prod->childcategory->category_relation)) { $sType = $prod->childcategory->category_relation->search_type; // if related with 'category' then show products under that category if ($prod->childcategory->category_relation->cs_category_type == 'App\Models\Category') { $countCsProds = \App\Models\Product::where('category_id', $prod->childcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'subcategory' then show products under that subcategory elseif ($prod->childcategory->category_relation->cs_category_type == 'App\Models\Subcategory') { $countCsProds = \App\Models\Product::where('subcategory_id', $prod->childcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'childcategory' then show products under that childcategory elseif ($prod->childcategory->category_relation->cs_category_type == 'App\Models\Childcategory') { $countCsProds = \App\Models\Product::where('childcategory_id', $prod->childcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } } // check if the product's subcategory is in `cs_category_relations` table elseif (!empty($prod->subcategory->category_relation)) { $sType = $prod->subcategory->category_relation->search_type; // if related with 'category' then show products under that category if ($prod->subcategory->category_relation->cs_category_type == 'App\Models\Category') { $countCsProds = \App\Models\Product::where('category_id', $prod->subcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'subcategory' then show products under that subcategory elseif ($prod->subcategory->category_relation->cs_category_type == 'App\Models\Subcategory') { $countCsProds = \App\Models\Product::where('subcategory_id', $prod->subcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'childcategory' then show products under that childcategory elseif ($prod->subcategory->category_relation->cs_category_type == 'App\Models\Childcategory') { $countCsProds = \App\Models\Product::where('childcategory_id', $prod->subcategory->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } } // check if the product's category is in `cs_category_relations` table elseif (!empty($prod->category->category_relation)) { $sType = $prod->category->category_relation->search_type; // if related with 'category' then show products under that category if ($prod->category->category_relation->cs_category_type == 'App\Models\Category') { $countCsProds = \App\Models\Product::where('category_id', $prod->category->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'subcategory' then show products under that subcategory elseif ($prod->category->category_relation->cs_category_type == 'App\Models\Subcategory') { $countCsProds = \App\Models\Product::where('subcategory_id', $prod->category->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } // if related with 'childcategory' then show products under that childcategory elseif ($prod->category->category_relation->cs_category_type == 'App\Models\Childcategory') { $countCsProds = \App\Models\Product::where('childcategory_id', $prod->category->category_relation->cs_category_id) ->when($sType == 'keyword', function ($query) use ($term) { return $query->whereRaw('MATCH (name) AGAINST (? IN BOOLEAN MODE)' , array($term)); }) ->whereNotIn('id', $crossIds)->count(); } } @endphp {{-- If This product belongs to vendor then apply this --}} @if($prod->user_id != 0) {{-- check If This vendor status is active --}} @if($prod->user->is_vendor == 2) @if(isset($_GET['max'])) @if($prod->vendorPrice() <= $_GET['max'])
@if(!empty($prod->features))
@foreach($prod->features as $key => $data1) {{ $prod->features[$key] }} @endforeach
@endif {{--
  • @if(Auth::guard('web')->check()) @else @endif
--}}

{{ $prod->showPrice() }}

{{ $prod->showName() }}
@if($prod->product_type == "affiliate") {{ $langg->lang251 }} @else @if($prod->emptyStock()) {{ $langg->lang78 }} @else @if (($prod->cross_selling_products()->count() + $countCsProds) > 0) {{-- if the product has cross selling products --}} {{ $langg->lang56 }} @else {{-- if the product does not have cross selling products --}} {{ $langg->lang56 }} @endif {{ $langg->lang251 }} @endif @endif
@endif @else
@if(!empty($prod->features))
@foreach($prod->features as $key => $data1) {{ $prod->features[$key] }} @endforeach
@endif {{--
  • @if(Auth::guard('web')->check()) @else @endif
--}}

{{ $prod->showPrice() }} {{ $prod->showPreviousPrice() }}

{{ $prod->showName() }}
@if($prod->product_type == "affiliate") {{ $langg->lang251 }} @else @if($prod->stock === 0) {{ $langg->lang78 }} @else @if (($prod->cross_selling_products()->count() + $countCsProds) > 0) {{-- if the product has cross selling products --}} {{ $langg->lang56 }} @else {{-- if the product does not have cross selling products --}} {{ $langg->lang56 }} @endif {{ $langg->lang251 }} @endif @endif
@endif @endif {{-- If This product belongs admin and apply this --}} @else
@if(!empty($prod->features))
@foreach($prod->features as $key => $data1) {{ $prod->features[$key] }} @endforeach
@endif {{--
  • @if(Auth::guard('web')->check()) @else @endif
--}}

{{ $prod->showPrice() }}

{{ $prod->showName() }}
@if($prod->product_type == "affiliate") {{ $langg->lang251 }} @else @if($prod->stock === 0) {{ $langg->lang78 }} @else @if (($prod->cross_selling_products()->count() + $countCsProds) > 0) {{-- if the product has cross selling products --}} {{ $langg->lang56 }} @else {{-- if the product does not have cross selling products --}} {{ $langg->lang56 }} @endif {{ $langg->lang251 }} @endif @endif
@endif