nitinjohnson

nitinjohnson

Member Since 1 Year Ago

Ahmedabad

at Full Time Freelancer

Experience Points 530
Experience Level 1

4,470 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

15 Jul
1 week ago

nitinjohnson started a new conversation Laravel Image Check Always Throws Status 401

Hi,

I am trying to save images from dropbox to my server. I have already done the code for that. I am also checking the HTTP status of the url before downloading the images with code. I am getting proper status but the issue is it always throws an error 401 even when i have put a condition to download images with status code 200 or 302. I am having the list of images in an excel file that i am importing with a package. I am using laravel Please help me.

Function to import images

        $product_type=$request->get('product_type');
        $category_id=$request->get('category_id');
        $category_level=$request->get('category_level');
        $filepath = $request->get('file_path');
        $total_rows = $request->get('total_rows');
        $start_index = $request->get('start_index');
        $row_counter_break = $request->get('row_counter_break');

        $data = Excel::load($filepath)->limit(false, ($start_index))->get();
        $dataArr = $data->toArray();
        $array = array_map('array_filter', $dataArr);
        $array = array_filter($array);

        if($start_index > $total_rows){
            return response()->json([
                'status' => 'complete',
                'product_type'=>$product_type,
                'category_id'=>$category_id,
                'category_level'=>$category_level,
                'file_path'=>$filepath,
                'total_rows'=>$total_rows,
                'start_index'=>0,
                'row_counter_break'=>$row_counter_break
            ]);
        } else {
            $rowCounter=0;            
            foreach($array as $value){
                $image_list=array();
                if(!empty($value['image1'])){
                    array_push($image_list,$value['image1']);
                }
                if(!empty($value['image2'])){
                    array_push($image_list,$value['image2']);
                }
                if(!empty($value['image3'])){
                    array_push($image_list,$value['image3']);
                }
                if(!empty($value['image4'])){
                    array_push($image_list,$value['image4']);
                }
                if(!empty($value['image5'])){
                    array_push($image_list,$value['image5']);
                }  
                
                foreach($image_list as $il){
                    if($rowCounter>=$row_counter_break)
                    break;  
                    
                    $status=self::CheckLinkStatus($il);
                    if($status==200){
                        if (strpos($il, "?dl=0") !== false) {
                            $image_url = str_replace("?dl=0","",$il);
                            $image_url = str_replace("www.dropbox.com","content.dropboxapi.com",$il);                            
                            $info = pathinfo($image_url);
                            $contents = file_get_contents($image_url,true);
                            $file =  $info['basename'];
                            file_put_contents(public_path('datauploads')."/".$file, $contents);
                        } else {                            
                            $img_status=self::CheckLinkStatus($il);                                
                            if($img_status!==404 && $img_status!==401){
                                $image_url = str_replace("www.dropbox.com","content.dropboxapi.com",$il); 
                                $info = pathinfo($image_url);
                                $contents = file_get_contents($image_url,true);
                                $file =  $info['basename'];
                                file_put_contents(public_path('datauploads')."/".$file, $contents);
                            }                                                   
                        }
                    }                                       
                } 

                $rowCounter++;
            }            

            return response()->json([
                'status' => 'success',
                'product_type'=>$product_type,
                'category_id'=>$category_id,
                'category_level'=>$category_level,
                'file_path'=>$filepath,
                'total_rows'=>$total_rows,
                'start_index'=>$start_index,
                'row_counter_break'=>$row_counter_break
            ]);
        }        
    }```

Function to Check image status
``` public static function CheckLinkStatus($image){
        $ch = curl_init($image);
        curl_setopt($ch, CURLOPT_NOBODY, true);
        curl_exec($ch);
        $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        return $retcode;
    }```
30 Jan
5 months ago

nitinjohnson started a new conversation How To Check For A String Against Json Encode Array In A Table In Laravel?

I am having an issue with a Laravel project. I have a few checkbox of computer specification which I want to check against the database field that I am having called tech_specs. This tech_specs field contains the serialize array of all the tech_specs that are available for that specific product. I just want to list out the products having that particular specification. One more thing I have divided the products into 3 levels of categories and currently all the products are placed within the 3rd level category. I am trying to check for the specs of the particular 3rd level category based on the url parameter. Please let me know how to proceed.

Controller Function:

public function GetPage(Request $request,$page_slug){

        $page_title=self::replaceAll($page_slug);
        $category_level1_id=null;
        $category_level2_id=null;
        $category_level3_id=null;
        $products=null;
        $products_count=null;
        $product_lookup=null;
        $page_breadcrumb=null;
        $product_type=null;
        $brand=null;
        $final_selected_brand=array();
        $tech_specs_filter=null;
        $specs_filters=null;

        //Sorting Vars
        $sort_by=$request->query('sort_by');
        $min_price=$request->query('min_price');
        $max_price=$request->query('max_price');

        //Filter Vars
        $product_condition=$request->query('product_condition');
        $product_brand=$request->query('brand');
        $is_assured=$request->query('assured');
        $is_cod_allowed=$request->query('cod');
        $product_specs=$request->query('tech_spec');


        $final_selected_brand=null;
        if(!empty($product_brand)){
            $final_selected_brand=explode('|',$product_brand);
        }

        $final_selected_brand_ids=null;
        if(!empty($final_selected_brand)){
            foreach($final_selected_brand as $fsb){
                $final_selected_brand_ids[]=self::GetBrandIDFromName($fsb);
            }
        }

        $final_selected_spec=null;
        if(!empty($product_specs)){
            $final_selected_spec=explode('|',$product_specs);
        }

        // Get the categories
        $getCatlvl1 = Category::whereCategorySlug($page_slug);
        $getCatlvl2 = SubCategory::whereCategorySlug($page_slug);
        $getCatlvl3 = SubCategoryLvl3::whereCategorySlug($page_slug);


        //Check if is category level 1
        if ($getCatlvl1->count()) {
            $category_level1_id = $getCatlvl1->pluck('id')->toArray();
            $product_type = $getCatlvl1->pluck('product_type')->toArray()[0];
            $category_level1_name = $getCatlvl1->pluck('category_name')->toArray()[0];

            $brand=Brand::where('product_type',$product_type)->orderBy('brand_name')->get();

            $category_level2_id = SubCategory::where('parent_category', $category_level1_id)
                ->pluck('id')
                ->toArray();

            $category_level3_id = SubCategoryLvl3::whereIn('parent_category', $category_level2_id)
                ->pluck('id')
                ->toArray();

            $product_lookup = DB::table('products')
                                ->where('is_approved','Yes')
                                ->where('category_level',3)
                                ->whereIn('category',$category_level3_id)
                                ->when($product_condition, function($query) use($product_condition){
                                    $query->where('product_condition', $product_condition);
                                })
                                ->when($is_assured, function($query) use($is_assured){
                                    $query->where('is_assured','Yes');
                                })
                                ->when($is_cod_allowed, function($query) use($is_cod_allowed){
                                    $query->where('merchant_allowed_for_cod','Yes');
                                })
                                ->when($final_selected_brand_ids, function($query) use($final_selected_brand_ids) {
                                    if(count($final_selected_brand_ids)>1){
                                        $query->whereIn('brand',$final_selected_brand_ids);
                                    } else {
                                        $query->where('brand',$final_selected_brand_ids[0]);
                                    }
                                })
                                ->when($min_price and $max_price, function($query) use($min_price, $max_price) {
                                    if($min_price=='+50000'){
                                        $query->where('selling_price','>=',$min_price);
                                        $query->where('selling_price',$max_price);
                                    } else if($max_price=='+50000'){
                                        $query->where('selling_price',$min_price);
                                        $query->where('selling_price','>=',$max_price);
                                    } else {
                                        $query->whereBetween('selling_price', [
                                            $min_price,
                                            $max_price
                                        ]);
                                    }
                                })
                                ->when($sort_by, function($query) use($sort_by) {
                                    if($sort_by=='high-price'){
                                        $query->orderBy('selling_price', 'DESC');
                                    }
                                    if($sort_by=='low-price'){
                                        $query->orderBy('selling_price', 'ASC');
                                    }
                                    if($sort_by=='new-arrivals'){
                                        $query->orderBy('id', 'DESC');
                                    }
                                });

            $page_breadcrumb.= '<li class="breadcrumb-item active" aria-current="page">'.$category_level1_name.'</li>';
        }

        //Check if is category level 2
        if ($getCatlvl2->count()) {

            $category_level2_id = $getCatlvl2->pluck('id')->toArray();
            $product_type = $getCatlvl2->pluck('product_type')->toArray()[0];
            $category_level2_name = $getCatlvl2->pluck('category_name')->toArray()[0];

            $brand=Brand::where('product_type',$product_type)->orderBy('brand_name')->get();

            $parent_id = $getCatlvl2->pluck('parent_category')->toArray()[0];
            $get_cat_parent_id = Category::where('id',$parent_id)->get()->toArray()[0];
            $category_level1_name = $get_cat_parent_id['category_name'];
            $category_level1_link = $get_cat_parent_id['category_slug'];

            $category_level3_id = SubCategoryLvl3::whereIn('parent_category', $category_level2_id)
                ->pluck('id')
                ->toArray();

            $product_lookup = DB::table('products')
                ->where('is_approved','Yes')
                ->where('category_level',3)
                ->whereIn('category',$category_level3_id)
                ->when($product_condition, function($query) use($product_condition){
                    $query->where('product_condition', $product_condition);
                })
                ->when($is_assured, function($query) use($is_assured){
                    $query->where('is_assured','Yes');
                })
                ->when($is_cod_allowed, function($query) use($is_cod_allowed){
                    $query->where('merchant_allowed_for_cod','Yes');
                })
                ->when($final_selected_brand_ids, function($query) use($final_selected_brand_ids) {
                    if(count($final_selected_brand_ids)>1){
                        $query->whereIn('brand',$final_selected_brand_ids);
                    } else {
                        $query->where('brand',$final_selected_brand_ids[0]);
                    }
                })
                ->when($min_price and $max_price, function($query) use($min_price, $max_price) {
                    if($min_price=='+50000'){
                        $query->where('selling_price','>=',$min_price);
                        $query->where('selling_price',$max_price);
                    } else if($max_price=='+50000'){
                        $query->where('selling_price',$min_price);
                        $query->where('selling_price','>=',$max_price);
                    } else {
                        $query->whereBetween('selling_price', [
                            $min_price,
                            $max_price
                        ]);
                    }
                })
                ->when($sort_by, function($query) use($sort_by) {
                    if($sort_by=='high-price'){
                        $query->orderBy('selling_price', 'DESC');
                    }
                    if($sort_by=='low-price'){
                        $query->orderBy('selling_price', 'ASC');
                    }
                    if($sort_by=='new-arrivals'){
                        $query->orderBy('id', 'DESC');
                    }
                });

            $page_breadcrumb.= '<li class="breadcrumb-item"><a href="'.url('/').'/'.$category_level1_link.'">'.$category_level1_name.'</a></li>';
            $page_breadcrumb.= '<li class="breadcrumb-item active">'.$category_level2_name.'</li>';

        }

        //Check if is category level 3
        if ($getCatlvl3->count()) {
            $category_level3_id = $getCatlvl3->pluck('id')->toArray();
            $product_type = $getCatlvl3->pluck('product_type')->toArray()[0];
            $category_level3_name = $getCatlvl3->pluck('category_name')->toArray()[0];

            $brand=Brand::where('product_type',$product_type)->orderBy('brand_name')->get();

            $matchThese=["product_type"=>$product_type,"category"=>$category_level3_id,"category_level"=>3];
            $tech_specs_filter=TechSpecsFilter::where($matchThese)->get()->toArray();

            if(!empty($tech_specs_filter)){
                $temp=$tech_specs_filter[0];
                $specs_filters=json_decode($temp['filter_specs']);
            }

            $parent_id_lvl2 = $getCatlvl3->pluck('parent_category')->toArray()[0];
            $get_cat_parent_id_lvl2 = SubCategory::where('id',$parent_id_lvl2)->get()->toArray()[0];

            $category_level2_name = $get_cat_parent_id_lvl2['category_name'];
            $category_level2_link = $get_cat_parent_id_lvl2['category_slug'];

            $get_cat_parent_id = Category::where('id',$get_cat_parent_id_lvl2['parent_category'])->get()->toArray()[0];
            $category_level1_name = $get_cat_parent_id['category_name'];
            $category_level1_link = $get_cat_parent_id['category_slug'];

            $product_lookup = DB::table('products')
                ->where('is_approved','Yes')
                ->where('category_level',3)
                ->whereIn('category',$category_level3_id)
                ->when($product_condition, function($query) use($product_condition){
                    $query->where('product_condition', $product_condition);
                })
                ->when($is_assured, function($query) use($is_assured){
                    $query->where('is_assured','Yes');
                })
                ->when($is_cod_allowed, function($query) use($is_cod_allowed){
                    $query->where('merchant_allowed_for_cod','Yes');
                })
                ->when($final_selected_brand_ids, function($query) use($final_selected_brand_ids) {
                    if(count($final_selected_brand_ids)>1){
                        $query->whereIn('brand',$final_selected_brand_ids);
                    } else {
                        $query->where('brand',$final_selected_brand_ids[0]);
                    }
                })
                /*->when($final_selected_spec, function($query) use($final_selected_spec) {
                    if(count($final_selected_spec)>1){
                        //$query->whereIn('brand',$final_selected_spec);
                    } else {
                        $query->where('brand',$final_selected_spec[0]);
                    }
                })*/
                ->when($min_price and $max_price, function($query) use($min_price, $max_price) {
                    if($min_price=='+50000'){
                        $query->where('selling_price','>=',$min_price);
                        $query->where('selling_price',$max_price);
                    } else if($max_price=='+50000'){
                        $query->where('selling_price',$min_price);
                        $query->where('selling_price','>=',$max_price);
                    } else {
                        $query->whereBetween('selling_price', [
                            $min_price,
                            $max_price
                        ]);
                    }
                })
                ->when($sort_by, function($query) use($sort_by) {
                    if($sort_by=='high-price'){
                        $query->orderBy('selling_price', 'DESC');
                    }
                    if($sort_by=='low-price'){
                        $query->orderBy('selling_price', 'ASC');
                    }
                    if($sort_by=='new-arrivals'){
                        $query->orderBy('id', 'DESC');
                    }
                });

            $page_breadcrumb.= '<li class="breadcrumb-item"><a href="'.url('/').'/'.$category_level1_link.'">'.$category_level1_name.'</a></li>';
            $page_breadcrumb.= '<li class="breadcrumb-item"><a href="'.url('/').'/'.$category_level2_link.'">'.$category_level2_name.'</a></li>';
            $page_breadcrumb.= '<li class="breadcrumb-item active">'.$category_level3_name.'</li>';
        }

        $temp_products =  $product_lookup->get();

        if(count($temp_products)>0){
            $products_count = $product_lookup->get()->count();
            $products = $product_lookup->paginate(50);
        }

        //Category Tree
        $content='<ul class="category-page-tree">';
        $get_category_tree_cat_level1 = Category::orderBy('category_name')->get();
        foreach($get_category_tree_cat_level1 as $gct1){
            $content.='<li>';
                $content.='<a href="'.url('/').'/'.$gct1->category_slug.'" class="level1_cat_color"><i class="fas fa-angle-right"></i> '.$gct1->category_name.'</a>';
                $get_category_tree_cat_level2 = SubCategory::orderBy('category_name')
                    ->where('parent_category',$gct1->id)
                    ->get();
                $content.='<ul>';
                    foreach($get_category_tree_cat_level2 as $gct2){
                        $content.='<li>';
                            $content.='<a href="'.url('/').'/'.$gct2->category_slug.'" class="level2_cat_color"><i class="fas fa-angle-right"></i> '.$gct2->category_name.'</a>';
                            $get_category_tree_cat_level3 = SubCategoryLvl3::orderBy('category_name')
                                ->where('parent_category',$gct2->id)
                                ->get();
                            $content.='<ul>';
                            foreach($get_category_tree_cat_level3 as $gct3){
                                $content.='<li>';
                                $content.='<a href="'.url('/').'/'.$gct3->category_slug.'" class="level3_cat_color"><i class="fas fa-angle-right"></i> '.$gct3->category_name.'</a>';
                                $content.='</li>';
                            }
                            $content.='</ul>';
                        $content.='</li>';
                    }
                $content.='</ul>';
            $content.='</li>';
        }
        $content.='</ul>';


        return view("frontend.pages.category_page")->with(
            array(
                'products'=>$products,
                'products_count'=>$products_count,
                'page_slug'=>$page_slug,
                'page_breadcrumb'=>$page_breadcrumb,
                'product_type'=>$product_type,
                'brands'=>$brand,
                'page_title'=>$page_title,
                'category_tree'=>$content,
                'category_level_column'=>2,
                'min_price'=>$min_price,
                'max_price'=>$max_price,
                'selected_brand'=>(array)$final_selected_brand,
                'is_assured'=>$is_assured,
                'is_cod_allowed'=>$is_cod_allowed,
                'specs_filters'=>$specs_filters,
                'selected_specs'=>(array)$final_selected_spec,
            )
        );
    }

jQuery Code:

$(document).on("click", ".tech_specs_filter_box input[type='checkbox']", function(e) {
        var selected_specs=$(this).val();
        var current_url=window.location.href;
        var page_slug=$("#page_slug").val();
        var url_parameters = [];
        var specs_append = [];

        //Parameters
        var product_condition = getParam('product_condition');
        var sort_by = getParam('sort_by');
        var min_price = getParam('min_price');
        var max_price = getParam('max_price');
        var brand = getParam('brand');
        var tech_spec = getParam('tech_spec');
        var to_add_quesion_mark='no';

        if($(this).prop("checked") == true){
            if(current_url.indexOf('?tech_spec') == -1){
                url_parameters.push('?tech_spec='+selected_specs);
            } else {
                if(current_url.indexOf('?tech_spec') !== -1){
                    specs_append.push('?tech_spec='+tech_spec);
                    specs_append.push('|'+selected_specs);
                    url_parameters.push(specs_append.join(""));
                } else if(current_url.indexOf('&tech_spec') !== -1){
                    specs_append.push('&tech_spec='+tech_spec);
                    specs_append.push('|'+selected_specs);
                    url_parameters.push(specs_append.join(""));
                } else if(current_url.indexOf('&tech_spec') !== -1) {
                    url_parameters.push('&tech_spec='+selected_specs);
                }
            }
        } else if($(this).prop("checked") == false) {

            var specsArr = [];
            $('.tech_specs_filter_box input:checked').each(function(index) {
                var temp_val=$(this).attr('id');
                specsArr.push($("#"+temp_val).val());
            });
            var getSpecStr = specsArr.join("|");

            if(getSpecStr!==""){
                if(current_url.indexOf('?tech_spec') !== -1){
                    url_parameters.push('?tech_spec='+getSpecStr);
                }
            } else {
                to_add_quesion_mark="yes";
            }
        }


        if(sort_by!==""){
            url_parameters.push('sort_by='+sort_by);
        }
        if(product_condition!==""){
            url_parameters.push('product_condition='+product_condition);
        }
        if(min_price!==""){
            url_parameters.push('min_price='+min_price);
        }
        if(max_price!==""){
            url_parameters.push('max_price='+max_price);
        }
        if(brand!==""){
            url_parameters.push('brand='+brand);
        }

        if(to_add_quesion_mark=='yes'){
            for(var i=0;i<url_parameters.length;i++){
                if(i==0) url_parameters[i] = '?'+url_parameters[i];
            }
        }

        target_location = url_parameters.join("&");
        window.location = page_slug+target_location;

    });
25 Jan
5 months ago

nitinjohnson left a reply on How To Dynamically Append Multiple Conditions To Laravel Query?

@BRAUNSON - @braunson Thank you very much. I really appreciate it. Worked for me.

nitinjohnson started a new conversation How To Dynamically Append Multiple Conditions To Laravel Query?

I have an issue that I am facing in Laravel. I am trying to append multiple conditions to a query. In other words I want to add multiple where conditions based on if a particular parameter has value or not. If the parameter has value it should be appended. I am making a product filter and currently I have added product condition and min and max price query conditions. I want both of them to work together.

Controller Function

        $product_condition=$request->get('product_condition');
        $min_price=$request->get('min_price');
        $max_price=$request->get('max_price');
        $page_slug=$request->get('page_slug');
        $products=null;
        $products2=null;
        $query_condition=null;

        $getCatlvl1=Category::where([
            ["category_slug","=",$page_slug]
        ])->get();

        $getCatlvl2=SubCategory::where([
            ["category_slug","=",$page_slug]
        ])->get();

        $getCatlvl3=SubCategoryLvl3::where([
            ["category_slug","=",$page_slug]
        ])->get();

        if(count($getCatlvl1)>0){
            $category_level1_id=null;
            $category_level2_id=null;
            $category_level3_id=null;

            foreach($getCatlvl1 as $gc){
                $category_level1_id=$gc->id;
            }

            $get_child_cat_level2=SubCategory::where('parent_category',$category_level1_id)->get();
            foreach($get_child_cat_level2 as $gc2){
                $category_level2_id[]=$gc2->id;
            }

            $get_child_cat_level3=SubCategoryLvl3::whereIn('parent_category',$category_level2_id)->get();
            foreach($get_child_cat_level3 as $gc3){
                $category_level3_id[]=$gc3->id;
            }

            $products = DB::table('products')
                ->where('category_level', 3)
                ->whereIn('category',$category_level3_id);

            $products2 = DB::table('products')
                ->where('category_level', 3)
                ->whereIn('category',$category_level3_id);

            if(!empty($product_condition)){
                $products->where('product_condition',$product_condition);
                $products2->where('product_condition',$product_condition);
            }

            if(!empty($min_price) && !empty($max_price)){
                $products->whereBetween('selling_price',[$min_price,$max_price]);
                $products2->whereBetween('selling_price',[$min_price,$max_price]);
            }

            $products = $products->paginate(40);
            $products2 = $products2->get();

            $filter_text_for_page=null;

            if(!empty($product_condition)){
                $filter_text_for_page.='<p class="mytagcloud"><strong>Condition:</strong> '.ucwords($product_condition).'</p>';
            }

            if(!empty($min_price) && !empty($max_price)){
                $filter_text_for_page.='<p class="mytagcloud"><strong>Price Range:</strong> '.$min_price.'-'.$max_price.'</p>';
            }

            return view('frontend.pages.category_load', [
                'products' => $products,
                'products_count'=>$products2->count(),
                'page_slug'=>$page_slug,
                'category_level_column'=> 2,
                'product_card_class '=> 'six_cols_card',
                'page_filter_text'=> $filter_text_for_page,
            ])->render();

        } else if(count($getCatlvl2)>0){

        } else if(count($getCatlvl3)>0){

        }

    } ```

jQuery Code

``` $(document).ready(function(){
//Filters
        $(".product_condition_filter").click(function(e){
            var selected_condition=$(this).val();
            $.ajax({
                url:"{{ route('category-page-filter') }}",
                type:"post",
                async:false,
                data:{product_condition:selected_condition, page_slug:$("#page_slug").val()},
                success:function(res){
                    $(".category_products_box").html(res);
                }
            });
        });

        $( "#price_range_slider" ).slider({
            range: true,
            min: 100,
            max: 50000,
            values: [ 1000, 5000 ],
            slide: function( event, ui ) {
                $(".slide_min_val").html(ui.values[0]);
                $(".slide_max_val").html(ui.values[1]);

                $.ajax({
                    url:"{{ route('category-page-filter') }}",
                    type:"post",
                    async:false,
                    data:{min_price:ui.values[0],max_price:ui.values[1], page_slug:$("#page_slug").val()},
                    success:function(res){
                        $(".category_products_box").html(res);
                    }
                });
            }
        });
}); ```
04 Nov
8 months ago

nitinjohnson started a new conversation Same Routes In Differnt Domain With Different Controllers

I am working on an ecommerce website I have an admin panel as well as seller panel. I have a product module in the admin panel. Actually i want to use the same module in the seller panel also but I want to use the same route for both of the panel. Seller panel is in sub domain and the admin panel is the main domain. I have also provided groups. Is it possible to use the same route with any conditional code without having to use different routes for both admin and seller panels. Please help me out.

//Seller Panel
Route::group(['domain' => 'seller.techmart.local'], function () {

    //Login
    Route::any('/', ['uses' => 'Frontend\Seller\Login\[email protected]', 'as' => 'login']);
    Route::any('/sellerlogin', ['uses' => 'Frontend\Seller\Login\[email protected]', 'as' => 'sellerlogin']);

    //Dashboard
    Route::any('/seller-dashboard', ['uses' => 'Frontend\Seller\Dashboard\[email protected]', 'as' => 'seller-dashboard']);
});

//Main Domain
Route::group(['domain' => 'techmart.local'], function () {

    //Admin Panel
    Route::group(['prefix' => 'masterpanel', 'middleware' => 'masterpanel'], function() {

        //login
        Route::any('/', ['uses' => 'Admin\[email protected]', 'as' => 'login']);
        Route::any('processlogin', ['uses' => 'Admin\[email protected]', 'as' => 'processlogin']);
        Route::any('/logout', ['uses' => 'Admin\[email protected]', 'as' => 'logout']);

        //dashboard
        Route::any('dashboard', ['uses' => 'Admin\[email protected]', 'as' => 'dashboard']);

        /********** Category **********/
        Route::any('/brand', ['uses' => 'Brand\[email protected]', 'as' => 'brand']);
        Route::any('/savebrand', ['uses' => 'Brand\[email protected]', 'as' => 'savebrand']);
        Route::any('/viewbrand/{id}', ['uses' => 'Brand\[email protected]', 'as' => 'viewbrand']);
        Route::any('/editbrand/{id}', ['uses' => 'Brand\[email protected]', 'as' => 'editbrand']);
        Route::any('/updatebrand', ['uses' => 'Brand\[email protected]', 'as' => 'updatebrand']);
        Route::any('/deletebrand', ['uses' => 'Brand\[email protected]', 'as' => 'deletebrand']);
        Route::any('/importbrand', ['uses' => 'Brand\[email protected]', 'as' => 'importbrand']);
        Route::any('/deleteselectedbrand', ['uses' => 'Brand\[email protected]', 'as' => 'deleteselectedbrand']);
        Route::any('/deleteallbrand', ['uses' => 'Brand\[email protected]', 'as' => 'deleteallbrand']);

        /********** Product Type **********/
        Route::any('/addproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'addproducttype']);
        Route::any('/saveproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'saveproducttype']);
        Route::any('/manageproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'manageproducttype']);
        Route::any('/editproducttype/{id}', ['uses' => 'ProductType\[email protected]', 'as' => 'editproducttype']);
        Route::any('/updateproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'updateproducttype']);
        Route::any('/deleteproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'deleteproducttype']);
        Route::any('/deleteselectedproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'deleteselectedproducttype']);

        /********** Category **********/
        //Category
        Route::any('/category', ['uses' => 'Category\[email protected]', 'as' => 'category']);
        Route::any('/savecategory', ['uses' => 'Category\[email protected]', 'as' => 'savecategory']);
        Route::any('/viewcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'viewcategory']);
        Route::any('/editcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'editcategory']);
        Route::any('/updatecategory', ['uses' => 'Category\[email protected]', 'as' => 'updatecategory']);
        Route::any('/deletecategory', ['uses' => 'Category\[email protected]', 'as' => 'deletecategory']);
        Route::any('/deleteselectedcategorylvl1', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl1']);

        Route::any('/view-subcategory-level3-manage', ['uses' => 'Category\[email protected]_Manage', 'as' => 'view-subcategory-level3-manage']);
        Route::any('/view-subcategory-level4-manage', ['uses' => 'Category\[email protected]_Manage', 'as' => 'view-subcategory-level4-manage']);

        //Sub Category
        Route::any('/category-level2', ['uses' => 'Category\[email protected]', 'as' => 'category-level2']);
        Route::any('/savesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategory']);
        Route::any('/viewsubcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'viewsubcategory']);
        Route::any('/editsubcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'editsubcategory']);
        Route::any('/updatesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategory']);
        Route::any('/deletesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategory']);
        Route::any('/deleteselectedcategorylvl2', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl2']);

        //Sub Category Lvl3
        Route::any('/category-level3', ['uses' => 'Category\[email protected]', 'as' => 'category-level3']);
        Route::any('/savesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategorylvl3']);
        Route::any('/view-subcategory-level3/{id}', ['uses' => 'Category\[email protected]', 'as' => 'view-subcategory-level3']);
        Route::any('/edit-subcategory-level3/{id}', ['uses' => 'Category\[email protected]', 'as' => 'edit-subcategory-level3']);
        Route::any('/updatesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategorylvl3']);
        Route::any('/deletesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategorylvl3']);
        Route::any('/deleteselectedcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl3']);

        //Sub Category Lvl4
        Route::any('/category-level4', ['uses' => 'Category\[email protected]', 'as' => 'category-level4']);
        Route::any('/savesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategorylvl4']);
        Route::any('/view-subcategory-level4/{id}', ['uses' => 'Category\[email protected]', 'as' => 'view-subcategory-level4']);
        Route::any('/edit-subcategory-level4/{id}', ['uses' => 'Category\[email protected]', 'as' => 'edit-subcategory-level4']);
        Route::any('/updatesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategorylvl4']);
        Route::any('/deletesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategorylvl4']);
        Route::any('/deleteselectedcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl4']);

        //Import Category
        Route::any('/categoryimport', ['uses' => 'Category\[email protected]', 'as' => 'categoryimport']);
        Route::any('/importcategorylvl1', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl1']);
        Route::any('/importcategorylvl2', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl2']);
        Route::any('/importcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl3']);
        Route::any('/importcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl4']);

        /********** Model **********/
        Route::any('/addmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'addmodel']);
        Route::any('/addmodelprocess', ['uses' => 'ModelComponent\[email protected]', 'as' => 'addmodelprocess']);
        Route::any('/importmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'importmodel']);
        Route::any('/importmodelprocess', ['uses' => 'ModelComponent\[email protected]', 'as' => 'importmodelprocess']);
        Route::any('/managemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'managemodel']);
        Route::any('/editmodel/{id}', ['uses' => 'ModelComponent\[email protected]', 'as' => 'editmodel']);
        Route::any('/updatemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'updatemodel']);
        Route::any('/deletemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'deletemodel']);
        Route::any('/deleteselectedmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'deleteselectedmodel']);

        /********** Tech Specs **********/
        Route::any('/addtechspecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'addtechspecsformat']);
        Route::any('/addtechspecsformatprocess', ['uses' => 'TechSpecs\[email protected]', 'as' => 'addtechspecsformatprocess']);
        Route::any('/specsgetmodel', ['uses' => 'TechSpecs\[email protected]', 'as' => 'specsgetmodel']);


        Route::any('/managespecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'managespecsformat']);
        Route::any('/viewspecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'viewspecsformat']);
        Route::any('/editspecsformat/{id}', ['uses' => 'TechSpecs\[email protected]', 'as' => 'editspecsformat']);
        Route::any('/deletespecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'deletespecsformat']);
        Route::any('/deleteselectedformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'deleteselectedformat']);


        /********** Products **********/
        Route::any('/products', ['uses' => 'Products\[email protected]', 'as' => 'products']);
        Route::any('/saveproduct', ['uses' => 'Products\[email protected]', 'as' => 'saveproduct']);
        Route::any('/viewproduct/{id}', ['uses' => 'Products\[email protected]', 'as' => 'viewproduct']);
        Route::any('/editproduct/{id}', ['uses' => 'Products\[email protected]', 'as' => 'editproduct']);
        Route::any('/updateproduct', ['uses' => 'Products\[email protected]', 'as' => 'updateproduct']);
        Route::any('/deleteproduct', ['uses' => 'Products\[email protected]', 'as' => 'deleteproduct']);

        Route::any('/productsgetbrand', ['uses' => 'Products\[email protected]', 'as' => 'productsgetbrand']);
        Route::any('/productgetsku', ['uses' => 'Products\[email protected]', 'as' => 'productgetsku']);
        //Route::any('/getselectedproductcat', ['uses' => 'Products\[email protected]', 'as' => 'getselectedproductcat']);

        Route::any('/productscategory', ['uses' => 'Products\[email protected]', 'as' => 'productscategory']);
        Route::any('/productsgetmodel', ['uses' => 'Products\[email protected]', 'as' => 'productsgetmodel']);
        Route::any('/productgettechspecs', ['uses' => 'Products\[email protected]', 'as' => 'productgettechspecs']);
        Route::any('/deleteselectedproducts', ['uses' => 'Products\[email protected]', 'as' => 'deleteselectedproducts']);

        /********** Attribute **********/
        //Attribute
        Route::any('/attribute', ['uses' => 'Attribute\[email protected]', 'as' => 'attribute']);
        Route::any('/save-attribute-set', ['uses' => 'Attribute\[email protected]', 'as' => 'save-attribute-set']);
        Route::any('/save-attribute', ['uses' => 'Attribute\[email protected]', 'as' => 'save-attribute']);

    });

    //Scraper
    Route::group(['prefix' => 'vendorpanel', 'middleware' => 'vendorpanel'], function() {

        //Login
        Route::any('/', ['uses' => 'Scraper\[email protected]', 'as' => 'login']);
        Route::any('processlogin-scraper', ['uses' => 'Scraper\[email protected]', 'as' => 'processlogin-scraper']);

        //dashboard
        Route::any('vendor-dashboard', ['uses' => 'Scraper\[email protected]', 'as' => 'vendor-dashboard']);
        Route::any('/logout-vendor', ['uses' => 'Scraper\[email protected]', 'as' => 'logout-vendor']);

        //Scraping
        Route::any('/process-scraping', ['uses' => 'Scraper\[email protected]', 'as' => 'process-scraping']);

    });

    //Frontend
    Route::get('/', function () {
        return view('frontend.welcome');
    });

});
03 Nov
8 months ago

nitinjohnson left a reply on Middleware Routing With Sub Doamin

Hi,

I solved the issue I had auth problem due to the auth it was getting redirected to the main domain middleware.

nitinjohnson started a new conversation Middleware Routing With Sub Doamin

Hi

I am trying to implement a sub domain routing but for some reason my middleware of the main domain page appears when i try to access the sub domain page. Please help me out. Can anyone tell me what I am doing wrong.

Routes Code

Route::group(['domain' => 'seller.techmart.local'], function () {
    Route::any('/', ['uses' => 'Frontend\Seller\Login\[email protected]', 'as' => 'login']);
});

Route::group(['domain' => 'techmart.local'], function () {
    //Admin Panel
    Route::group(['prefix' => 'masterpanel', 'middleware' => 'masterpanel'], function() {

        //login
        Route::any('/', ['uses' => 'Admin\[email protected]', 'as' => 'login']);
        Route::any('processlogin', ['uses' => 'Admin\[email protected]', 'as' => 'processlogin']);
        Route::any('/logout', ['uses' => 'Admin\[email protected]', 'as' => 'logout']);

        //dashboard
        Route::any('dashboard', ['uses' => 'Admin\[email protected]', 'as' => 'dashboard']);

        /********** Category **********/
        Route::any('/brand', ['uses' => 'Brand\[email protected]', 'as' => 'brand']);
        Route::any('/savebrand', ['uses' => 'Brand\[email protected]', 'as' => 'savebrand']);
        Route::any('/viewbrand/{id}', ['uses' => 'Brand\[email protected]', 'as' => 'viewbrand']);
        Route::any('/editbrand/{id}', ['uses' => 'Brand\[email protected]', 'as' => 'editbrand']);
        Route::any('/updatebrand', ['uses' => 'Brand\[email protected]', 'as' => 'updatebrand']);
        Route::any('/deletebrand', ['uses' => 'Brand\[email protected]', 'as' => 'deletebrand']);
        Route::any('/importbrand', ['uses' => 'Brand\[email protected]', 'as' => 'importbrand']);
        Route::any('/deleteselectedbrand', ['uses' => 'Brand\[email protected]', 'as' => 'deleteselectedbrand']);
        Route::any('/deleteallbrand', ['uses' => 'Brand\[email protected]', 'as' => 'deleteallbrand']);

        /********** Product Type **********/
        Route::any('/addproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'addproducttype']);
        Route::any('/saveproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'saveproducttype']);
        Route::any('/manageproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'manageproducttype']);
        Route::any('/editproducttype/{id}', ['uses' => 'ProductType\[email protected]', 'as' => 'editproducttype']);
        Route::any('/updateproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'updateproducttype']);
        Route::any('/deleteproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'deleteproducttype']);
        Route::any('/deleteselectedproducttype', ['uses' => 'ProductType\[email protected]', 'as' => 'deleteselectedproducttype']);

        /********** Category **********/
        //Category
        Route::any('/category', ['uses' => 'Category\[email protected]', 'as' => 'category']);
        Route::any('/savecategory', ['uses' => 'Category\[email protected]', 'as' => 'savecategory']);
        Route::any('/viewcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'viewcategory']);
        Route::any('/editcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'editcategory']);
        Route::any('/updatecategory', ['uses' => 'Category\[email protected]', 'as' => 'updatecategory']);
        Route::any('/deletecategory', ['uses' => 'Category\[email protected]', 'as' => 'deletecategory']);
        Route::any('/deleteselectedcategorylvl1', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl1']);

        Route::any('/view-subcategory-level3-manage', ['uses' => 'Category\[email protected]_Manage', 'as' => 'view-subcategory-level3-manage']);
        Route::any('/view-subcategory-level4-manage', ['uses' => 'Category\[email protected]_Manage', 'as' => 'view-subcategory-level4-manage']);

        //Sub Category
        Route::any('/category-level2', ['uses' => 'Category\[email protected]', 'as' => 'category-level2']);
        Route::any('/savesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategory']);
        Route::any('/viewsubcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'viewsubcategory']);
        Route::any('/editsubcategory/{id}', ['uses' => 'Category\[email protected]', 'as' => 'editsubcategory']);
        Route::any('/updatesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategory']);
        Route::any('/deletesubcategory', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategory']);
        Route::any('/deleteselectedcategorylvl2', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl2']);

        //Sub Category Lvl3
        Route::any('/category-level3', ['uses' => 'Category\[email protected]', 'as' => 'category-level3']);
        Route::any('/savesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategorylvl3']);
        Route::any('/view-subcategory-level3/{id}', ['uses' => 'Category\[email protected]', 'as' => 'view-subcategory-level3']);
        Route::any('/edit-subcategory-level3/{id}', ['uses' => 'Category\[email protected]', 'as' => 'edit-subcategory-level3']);
        Route::any('/updatesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategorylvl3']);
        Route::any('/deletesubcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategorylvl3']);
        Route::any('/deleteselectedcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl3']);

        //Sub Category Lvl4
        Route::any('/category-level4', ['uses' => 'Category\[email protected]', 'as' => 'category-level4']);
        Route::any('/savesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'savesubcategorylvl4']);
        Route::any('/view-subcategory-level4/{id}', ['uses' => 'Category\[email protected]', 'as' => 'view-subcategory-level4']);
        Route::any('/edit-subcategory-level4/{id}', ['uses' => 'Category\[email protected]', 'as' => 'edit-subcategory-level4']);
        Route::any('/updatesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'updatesubcategorylvl4']);
        Route::any('/deletesubcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'deletesubcategorylvl4']);
        Route::any('/deleteselectedcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'deleteselectedcategorylvl4']);

        //Import Category
        Route::any('/categoryimport', ['uses' => 'Category\[email protected]', 'as' => 'categoryimport']);
        Route::any('/importcategorylvl1', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl1']);
        Route::any('/importcategorylvl2', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl2']);
        Route::any('/importcategorylvl3', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl3']);
        Route::any('/importcategorylvl4', ['uses' => 'Category\[email protected]', 'as' => 'importcategorylvl4']);

        /********** Model **********/
        Route::any('/addmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'addmodel']);
        Route::any('/addmodelprocess', ['uses' => 'ModelComponent\[email protected]', 'as' => 'addmodelprocess']);
        Route::any('/importmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'importmodel']);
        Route::any('/importmodelprocess', ['uses' => 'ModelComponent\[email protected]', 'as' => 'importmodelprocess']);
        Route::any('/managemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'managemodel']);
        Route::any('/editmodel/{id}', ['uses' => 'ModelComponent\[email protected]', 'as' => 'editmodel']);
        Route::any('/updatemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'updatemodel']);
        Route::any('/deletemodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'deletemodel']);
        Route::any('/deleteselectedmodel', ['uses' => 'ModelComponent\[email protected]', 'as' => 'deleteselectedmodel']);

        /********** Tech Specs **********/
        Route::any('/addtechspecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'addtechspecsformat']);
        Route::any('/addtechspecsformatprocess', ['uses' => 'TechSpecs\[email protected]', 'as' => 'addtechspecsformatprocess']);
        Route::any('/specsgetmodel', ['uses' => 'TechSpecs\[email protected]', 'as' => 'specsgetmodel']);


        Route::any('/managespecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'managespecsformat']);
        Route::any('/viewspecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'viewspecsformat']);
        Route::any('/editspecsformat/{id}', ['uses' => 'TechSpecs\[email protected]', 'as' => 'editspecsformat']);
        Route::any('/deletespecsformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'deletespecsformat']);
        Route::any('/deleteselectedformat', ['uses' => 'TechSpecs\[email protected]', 'as' => 'deleteselectedformat']);


        /********** Products **********/
        Route::any('/products', ['uses' => 'Products\[email protected]', 'as' => 'products']);
        Route::any('/saveproduct', ['uses' => 'Products\[email protected]', 'as' => 'saveproduct']);
        Route::any('/viewproduct/{id}', ['uses' => 'Products\[email protected]', 'as' => 'viewproduct']);
        Route::any('/editproduct/{id}', ['uses' => 'Products\[email protected]', 'as' => 'editproduct']);
        Route::any('/updateproduct', ['uses' => 'Products\[email protected]', 'as' => 'updateproduct']);
        Route::any('/deleteproduct', ['uses' => 'Products\[email protected]', 'as' => 'deleteproduct']);

        Route::any('/productsgetbrand', ['uses' => 'Products\[email protected]', 'as' => 'productsgetbrand']);
        Route::any('/productgetsku', ['uses' => 'Products\[email protected]', 'as' => 'productgetsku']);
        //Route::any('/getselectedproductcat', ['uses' => 'Products\[email protected]', 'as' => 'getselectedproductcat']);

        Route::any('/productscategory', ['uses' => 'Products\[email protected]', 'as' => 'productscategory']);
        Route::any('/productsgetmodel', ['uses' => 'Products\[email protected]', 'as' => 'productsgetmodel']);
        Route::any('/productgettechspecs', ['uses' => 'Products\[email protected]', 'as' => 'productgettechspecs']);
        Route::any('/deleteselectedproducts', ['uses' => 'Products\[email protected]', 'as' => 'deleteselectedproducts']);

        /********** Attribute **********/
        //Attribute
        Route::any('/attribute', ['uses' => 'Attribute\[email protected]', 'as' => 'attribute']);
        Route::any('/save-attribute-set', ['uses' => 'Attribute\[email protected]', 'as' => 'save-attribute-set']);
        Route::any('/save-attribute', ['uses' => 'Attribute\[email protected]', 'as' => 'save-attribute']);

    });

    //Scraper
    Route::group(['prefix' => 'vendorpanel', 'middleware' => 'vendorpanel'], function() {

        //Login
        Route::any('/', ['uses' => 'Scraper\[email protected]', 'as' => 'login']);
        Route::any('processlogin-scraper', ['uses' => 'Scraper\[email protected]', 'as' => 'processlogin-scraper']);

        //dashboard
        Route::any('vendor-dashboard', ['uses' => 'Scraper\[email protected]', 'as' => 'vendor-dashboard']);
        Route::any('/logout-vendor', ['uses' => 'Scraper\[email protected]', 'as' => 'logout-vendor']);

        //Scraping
        Route::any('/process-scraping', ['uses' => 'Scraper\[email protected]', 'as' => 'process-scraping']);

    });
});



//Frontend
Route::get('/', function () {
    return view('frontend.welcome');
});```
22 May
1 year ago

nitinjohnson left a reply on Not Able To Create Controller With Command Line?

ok i just figured out i was directly setting up the composer installation checking on the developer option allow me to select the other php versions available.

nitinjohnson left a reply on Not Able To Create Controller With Command Line?

How to upgrade the cli version can you please suggest

nitinjohnson started a new conversation Not Able To Create Controller With Command Line?

I have got the setup of latest laravel from my client but when i try to create new controller its showing the below error. Please help me solve this.

Parse error: syntax error, unexpected '?' in C:\wamp\www\elatetech\celebrity\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php on line 233

21 Apr
1 year ago

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

i have put an if and else condition so only the fields will be loaded only once so if the user clicks on the edit button for the first time the field values will be blank and if he is editing it then the values will be already there.

To put is simple for the multiselect chosen i have used hidden input fields i am storing its value on the change event of the select so they are not having names

and it isn't getting duplicated due to the if else condition

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

actually i am saving the user details first time the user enters the details it will be saved to the database but it the user id already exists in the database then the values will be updated to that user id

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

yes i think its client side issue but to confirm i checked even with different browsers and even tried on my friend's pc there also it was returning the same result

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

i know we can get with the request all but just did this but that is not the issue even before i send the code to the controller i tried to alert the serialize the form and alert the data even then i am getting blank values for the text input fields

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

I have formatted the code please check

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

oh, sorry I forgot to put that code in the question. Pl check below code:

public function SaveUserDetailsForm(Request $request){ $user_id=$this->getSessionData('CURRENT_USER_ID'); $languages=$request->get('languages'); $sex=$request->get('sex'); $age=$request->get('age'); $job=$request->get('job'); $hobbies=$request->get('hobbies'); $smoking=$request->get('smoking'); $country=$request->get('country'); $state=$request->get('state'); $city=$request->get('city'); $facebook=$request->get('facebook'); $twitter=$request->get('twitter'); $instagram=$request->get('instagram'); $linkedin=$request->get('linkedin'); $mytime = Carbon::now()->toDateTimeString();

    $check_status = DB::table("user_details")
        ->where("user_id", "=",  $user_id)
        ->get();

    $row_count=count($check_status);

    $validator = Validator::make($request->all(), [
        'languages' => 'required',
        'state' => 'required',
        'city' => 'required',
    ]);

    if ($validator->passes()) {

        if($row_count==0){
            $mydetails = new UserDetail();
            $mydetails->user_id = $user_id;
            $mydetails->languages = $languages;
            $mydetails->sex = $sex;
            $mydetails->age = $age;
            $mydetails->job = $job;
            $mydetails->hobbies = $hobbies;
            $mydetails->smoking = $smoking;
            $mydetails->country = $country;
            $mydetails->state = $state;
            $mydetails->city = $city;
            $mydetails->social_media = serialize(array($facebook,$twitter,$instagram,$linkedin));
            $mydetails->created_at = $mytime;
            $mydetails->updated_at = $mytime;
            $mydetails->save();
        } else {
            DB::table('user_details')
                ->where('user_id', $user_id)
                ->update([
                    'languages' => $languages,
                    'sex' => $sex,
                    'age' => $age,
                    'job' => $job,
                    'hobbies' => $hobbies,
                    'smoking' => $smoking,
                    'country' => $country,
                    'state' => $state,
                    'city' => $city,
                    'social_media' => serialize(array($facebook,$twitter,$instagram,$linkedin)),
                    //'created_at' => $mytime,
                    'updated_at' => $mytime,
                ]);
        }

    }


    return response()->json(['error'=>$validator->errors()->all()]);
    
}

nitinjohnson left a reply on Input Type Text Values Getting Blank After Form Submission

the delete status is just to get the value of a checkbox and the DoServerHttpAsyncCall is similar to the ajax async request its working completely just the text fields values are becoming blank while i save them to the database.

nitinjohnson started a new conversation Input Type Text Values Getting Blank After Form Submission

I am working on a laravel application and it was working fine till yesterday but a new issue has come up now and I am totally confused how to solve this issue. I am submitting a form via ajax and and sending the serialized values to the controller but surprisingly the text field values becomes blank before submission. Please help me out.

View blade file

User Details

            {{--Fresh User--}}
            @if($edit_status=="new")
            <div class="row">
                <div class="col-md-4">
                    <label>Languages</label>
                    <select data-placeholder="Select a Language..." multiple class="languages">
                        <?php
                        foreach($languages as $lang){
                        ?>
                            <option value="{{ $lang->name }}">{{ $lang->name }}</option>
                        <?php } ?>
                    </select>
                </div>
                <div class="col-lg-4">
                    <label>Sex</label>
                    <select name="sex" class="form-control">
                        <option value="Male">Male</option>
                        <option value="Female">Female</option>
                    </select>
                </div>
                <div class="col-lg-4">
                    <label>Age</label>
                    <select name="age" class="form-control">
                        @for($i=18;$i<=120;$i++)
                            <option value="{{ $i }}">{{ $i }}</option>
                        @endfor
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                    <label>Job</label>
                    <input type="text" name="job" class="form-control" />
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-6">
                    <label>Hobbies</label>
                    <select data-placeholder="Select a Language..." multiple class="hobbies">
                        <?php
                        foreach($hobbies as $hobby){
                        ?>
                        <option>{{ $hobby->hobby_name }}</option>
    
                        <?php } ?>
                    </select>
                </div>
                <div class="col-lg-6">
                    <label>Smoking</label>
                    <select name="smoking" class="form-control">
                        <option value="Non-smoker">Non-smoker</option>
                        <option value="Somking sometimes">Somking sometimes</option>
                        <option value="Heavy smoker">Heavy smoker</option>
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-4">
                    <label>Countries</label>
                    <select data-placeholder="Select a Country..." class="countries">
                        <option selected="selected" value=""/>
                        <?php
                        foreach($countries as $country){
                        ?>
                            <option value="{{ $country->id }}">{{ $country->name }}</option>
                        <?php } ?>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>States</label>
                    <select data-placeholder="Select a State..." class="states">
    
                    </select>
                </div>
                <div class="col-md-4">
                    <label>Cities</label>
                    <select data-placeholder="Select a City..." class="cities">
    
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                    <p>
                        <label>Facebook </label>
                        <input type="text" name="facebook" placeholder="Facebook" class="form-control" />
                    </p>
                    <p>
                        <label>Twitter </label>
                        <input type="text" name="twitter" placeholder="Twitter" class="form-control" />
                    </p>
                    <p>
                        <label>Instagram </label>
                        <input type="text" name="instagram" placeholder="Instagram" class="form-control"  />
                    </p>
                    <p>
                        <label>LinkedIn </label>
                        <input type="text" name="linkedin" placeholder="LinkedIn" class="form-control" />
                    </p>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                    <input type="button" class="btn pull-right" onclick="SaveUserDetailsForm(this)" value="Update"/>
                </div>
            </div>
            @else
    
            {{--Old User--}} 
            <div class="row">
                <div class="col-md-4">
                    <label>Languages</label>
                    <select data-placeholder="Select a Language..." multiple class="languages">
                        <?php                            
                            foreach($languages as $lang){                                
                        ?>
                                <option>{{ $lang->name }}</option>                       
                        <?php } ?>
                    </select>                    
                </div>
                <div class="col-lg-4">
                    <label>Sex</label>
                    <select name="sex" class="form-control">
                        <option value="Male" <?php if($user_details->sex=='Male'){?> selected <?php }?>>Male</option>
                        <option value="Female" <?php if($user_details->sex=='Female'){?> selected <?php }?>>Female</option>
                    </select>
                </div>
                <div class="col-lg-4">
                    <label>Age</label>
                    <select name="age" class="form-control">
                        @for($i=18;$i<=120;$i++)
                            <option value="{{ $i }}" <?php if($user_details->age==$i){?> selected <?php } ?>>{{ $i }}</option>
                        @endfor
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                        <label>Job</label>
                        <input type="text" name="job" class="form-control" value="{{ $user_details->job }}" />
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-6">
                    <label>Hobbies</label>
                    <select data-placeholder="Select a Language..." multiple class="hobbies">
                        <?php
    
                        foreach($hobbies as $hobby){                        
                        ?>
                                <option >{{ $hobby->hobby_name }}</option>                            
                        <?php } ?>
                    </select>
                </div>
                <div class="col-lg-6">
                    <label>Smoking</label>
                    <select name="smoking" class="form-control">
                        <option value="Non-smoker" <?php if($user_details->smoking=='Non-smoker'){?> selected <?php }?>>Non-smoker</option>
                        <option value="Somking sometimes" <?php if($user_details->smoking=='Somking sometimes'){?> selected <?php }?>>Somking sometimes</option>
                        <option value="Heavy smoker" <?php if($user_details->smoking=='Heavy smoker'){?> selected <?php }?>>Heavy smoker</option>
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-4">
                    <label>Countries</label>
                    <select data-placeholder="Select a Country..." class="countries">
                        <option selected="selected" value=""/>
                        <?php
                        foreach($countries as $country){
                        ?>
                        <option value="{{ $country->id }}" <?php if($user_details->country==$country->id){?> selected <?php } ?>>{{ $country->name }}</option>
                        <?php } ?>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>States</label>
                    <select data-placeholder="Select a State..." class="states">
                        <?php foreach($states as $state_key=>$state_value){?>
                            <option value="{{ $state_key }}" <?php if($state_key==$user_details->state){?> selected <?php }?>>{{ $state_value }}</option>
                        <?php } ?>
                    </select>
                </div>
                <div class="col-md-4">
                    <label>Cities</label>
                    <select data-placeholder="Select a City..." class="cities">
                        <?php foreach($cities as $city_key=>$city_name){?>
                            <option value="{{ $city_key }}" <?php if($city_key==$user_details->city){?> selected <?php }?>>{{ $city_name }}</option>
                            <?php } ?>
                    </select>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                    <p>
                        <label>Facebook </label>
                        <input type="text" name="facebook" placeholder="Facebook" class="form-control" value="{{ $facebook }}" />
                    </p>
                    <p>
                        <label>Twitter </label>
                        <input type="text" name="twitter" placeholder="Twitter" class="form-control" value="{{ $twitter }}" />
                    </p>
                    <p>
                        <label>Instagram </label>
                        <input type="text" name="instagram" placeholder="Instagram" class="form-control" value="{{ $instagram }}" />
                    </p>
                    <p>
                        <label>LinkedIn </label>
                        <input type="text" name="linkedin" placeholder="LinkedIn" class="form-control" value="{{ $linkedin }}" />
                    </p>
                </div>
            </div>
    
            <div class="row">
                <div class="col-md-12">
                    <input type="button" class="btn pull-right" onclick="SaveUserDetailsForm(this)" value="Update"/>
                </div>
            </div>
    
            @endif
    
            @if($edit_status=="new")
            <input type="hidden" id="selectedlanguages" name="languages" value="" />
            <input type="hidden" id="selectedhobbies" name="hobbies" value="" />
            <input type="hidden" id="selectedcountry" name="country" value="" />
            <input type="hidden" id="selectedstate" name="state" value="" />
            <input type="hidden" id="selectedcity" name="city" value="" />
            @else
            <input type="hidden" id="selectedlanguages" name="languages" value="{{ $known_languages }}" />
            <input type="hidden" id="selectedhobbies" name="hobbies" value="{{ $my_hobbies }}" />
            <input type="hidden" id="selectedcountry" name="country" value="{{ $country_id }}" />
            <input type="hidden" id="selectedstate" name="state" value="{{ $state_id }}" />
            <input type="hidden" id="selectedcity" name="city" value="{{ $city_id }}" />
            @endif
    
    
        </form>
    

    Javascript Code

    function SaveProfileUser(self){ var $self = $(self); var $form = $("#profile_user"); var data = $form.serialize();

                var delete_status=$("#deleteaccountoption").val();
                 DoServerHttpAsyncCall('/save-profile',function(response){
                     //closeProfilePagePopup();
                     var delete_status=$("#deleteaccountoption").val();
                     if(delete_status==="checked"){
                         redirectLocation('/deleteaccount');
                     } else if(delete_status==="notchecked") {
                        redirectLocation('/home');
                }
    
     },null,data,true);
    

    }

    Contorller Code

    public function EditUserDetails(){ $mytime = Carbon::now()->toDateTimeString(); $user_id=$this->getSessionData('CURRENT_USER_ID');

        $check_user_data_status=UserDetail::where('user_id',$user_id)->first();
        $countries=Countries::all();
        $languages=Language::all();
        $hobbies=Hobby::all();
        $data='';
    
        if(count($check_user_data_status)>0){
    
            $current_user_details=UserDetail::where('user_id',$user_id)->first();
            $known_languages=$current_user_details->languages;
            $my_hobbies=$current_user_details->hobbies;
    
            $states_array=State::where('country_id',$current_user_details->country)->get();
            $cities_array=Cities::where('state_id',$current_user_details->state)->get();
    
            $states=array();
            $cities=array();
    
            foreach($states_array as $sta){
                $states[$sta->id]=$sta->name;
            }
    
            foreach($cities_array as $cta){
                $cities[$cta->id]=$cta->name;
            }
    
            $social_media=unserialize($current_user_details->social_media);
            $facebook=$social_media[0];
            $twitter=$social_media[1];
            $instagram=$social_media[2];
            $linkedin=$social_media[3];
    
            $data=array(
                "countries"=>$countries,
                "states"=>$states,
                "cities"=>$cities,
                "languages"=>$languages,
                "hobbies"=>$hobbies,
                "user_details"=>$current_user_details,
                "known_languages"=>$known_languages,
                "my_hobbies"=>$my_hobbies,
                "facebook"=>$facebook,
                "twitter"=>$twitter,
                "instagram"=>$instagram,
                "linkedin"=>$linkedin,
                "edit_status"=>"old",
                "country_id"=>$current_user_details->country,
                "state_id"=>$current_user_details->state,
                "city_id"=>$current_user_details->city
            );
        } else {
            $data=array(
                "countries"=>$countries,
                "languages"=>$languages,
                "hobbies"=>$hobbies,
                "edit_status"=>"new"
            );
        }
    
        return view('travels.edit_user_details')->with($data);
    }