Displaying issue

  Fri 10 / 03 / 2023

  Posted by: Muhammad babar Khan

Category : Laravel

Tags : laravel , php

Post Thumbnail
Description

sir kindCategory() function me jo he wohi sab 1 function se kese show karun

karna kuch kis tarha he k jab flex per click karen to property kinds show hongi or first property kind me jo categories hen wo show honi chahiyen lekin ab index function me to ($id) nahi aa rahi to ye kese kar sakte hen.  men aap ko sample image dikhata hun jisko follow kar raha hun .image me oper navbar me kinds hen or neeche categories 


View Code
                        public function index()
    {

        $this->kind = PropertyKind::all();
            return view('propertyv2::flex.index', $this->data);


    }
    public function kindCategory($id)
    {
         $this->kind = PropertyKind::all();
        $this->category = Propertyv2Category::where('kind',$id)->get();


        return view('propertyv2::flex.categories', $this->data);
    }
                
  Answered by CDL

Ap condition apply kr skty hain let me give you example


if ($request->category) { // agr category pe click ho ga to if exceute ho gi

    $this->kind= Propertyv2Category::where('kind',$id)->get();

}

else {

   $this->kind = PropertyKind::all();

}

return view('propertyv2::flex.categories', $this->kind);

Solved
  Comment   Share
0 Likes   2 Comments


comment-author
Muhammad babar Khan Author

$this->kind= Propertyv2Category::where('kind',$id)->get(); is tarha to index function ko bhi $id chahiye hogi jisk liye route me bhi lagaon ?



Reply


commented 1 year ago
comment-author
Hadayat Niazi Super Admin

yes optional route bna lein k id aa jaey to get kr ley otherwise all posts return kr dey



comment-author
Hadayat Niazi Super Admin

If your problem is resolved, please mark this as solved. Thank you



Reply


commented 1 year ago