@extends('front.layout.master')
@php
/** Seo of category pages */
if(request()->keyword){
$title = __('Showing all results for :keyword',['keyword' => request()->keyword]);
$seodes = $title;
}
else if(request()->chid)
{
$findchid = App\Grandcategory::find(request()->chid);
$title = __(':title - All products | ',['title' => $findchid->title]);
$seodes = strip_tags($findchid->description);
$seoimage = url('images/grandcategory/'.$findchid->image);
}
else if(request()->sid)
{
$findsubcat = App\Subcategory::find(request()->sid);
$title = __(':title - All products | ',['title' => $findsubcat->title]);
$seodes = strip_tags($findsubcat->description);
$seoimage = url('images/subcategory/'.$findsubcat->image);
}else{
$findcat = App\Category::find(request()->category);
$title = __(':title - All products | ',['title' => $findcat->title]);
$seodes = strip_tags($findcat->description);
$seoimage = url('images/category/'.$findcat->image);
}
/* End */
@endphp
@section('meta_tags')
@php
$last_cat = 0;
$first_cat = 0;
$price_login = App\Genral::first()->login;
$price_array = array();
$convert_price = 0;
$show_price = 0;
$s_product = App\SimpleProduct::query();
$get_simple_products = array();
$all_brands_products = array();
if ($tag != '')
{
try
{
if ($chid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
$all_products_brands = $get_all_products->whereIn('brand_id', $brand_names)->where('tags', $tag)->where('grand_id', $chid)->get();
$get_simple_products = $s_product->whereIn('brand_id', $brand_names)->where('product_tags', $tag)->where('child_id', $chid);
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('grand_id', $chid)->get();
$get_simple_products = $s_product->where('product_tags', $tag)->where('child_id', $chid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($sid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('tags', $tag)->where('child', $sid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
$get_simple_products = $s_product->whereIn('brand_id', $brand_names)->where('product_tags', $tag)->where('subcategory_id', $sid);
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('child', $sid)->get();
$get_simple_products = $s_product->where('product_tags', $tag)->where('subcategory_id', $sid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('tags', $tag)->where('category_id', $catid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
$get_simple_products = $s_product
->where('product_tags', $tag)
->whereIn('brand_id', $brand_names)
->where('category_id', $catid);
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('tags', $tag)->where('category_id', $catid)->get();
$get_simple_products = $s_product
->where('product_tags', $tag)
->where('category_id', $catid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
}
}
catch(Exception $e)
{
$last_cat = 0;
$first_cat = 0;
}
}
else
{
try
{
if ($chid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('grand_id', $chid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
$get_simple_products = $s_product
->whereIn('brand_id', $brand_names)
->where('child_id', $chid);
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('grand_id', $chid)->get();
$get_simple_products = $s_product->where('child_id', $chid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($sid != '')
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('child', $sid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
$get_simple_products = $s_product
->whereIn('brand_id', $brand_names)
->where('subcategory_id', $sid);
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('child', $sid)->get();
$get_simple_products = $s_product->where('subcategory_id', $sid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
else
{
if ($brand_names != '')
{
$get_all_products = App\Product::query();
if (is_array($brand_names))
{
foreach ($brand_names as $brands_all)
{
$all_products_brands = $get_all_products->where('brand_id', $brands_all)->where('category_id', $catid)->get();
foreach ($all_products_brands as $zx)
{
array_push($all_brands_products, $zx);
}
}
$get_simple_products = $s_product
->whereIn('brand_id', $brand_names)
->where('category_id', $catid);
}
if ($all_brands_products == null)
{
$first_cat = 0;
$last_cat = 0;
}
else
{
$productsfor_price = $all_brands_products;
}
}
else
{
$productsfor_price = App\Product::where('category_id', $catid)->get();
$get_simple_products = $s_product->where('subcategory_id', $sid);
}
foreach ($productsfor_price as $old)
{
foreach ($old->subvariants as $orivar)
{
if ($price_login == 0 || Auth::user())
{
$customer_price = ProductPrice::getprice($old,$orivar)->getData()->customer_price;
array_push($price_array, $totalprice);
}
}
}
foreach ($get_simple_products->get() as $key => $sp) {
if ($price_login == 0 || Auth::user())
{
if($sp->offer_price != 0){
array_push($price_array, $sp->offer_price);
}else{
array_push($price_array, $sp->price);
}
}
}
if ($price_array != null)
{
$first_cat = min($price_array);
$last_cat = max($price_array);
}
unset($price_array);
$price_array = array();
}
}
}
catch(Exception $e)
{
$last_cat = 0;
$first_cat = 0;
}
}
@endphp