πŸ’¬
WhatsApp Support

Hello! How can we help you?

 Back

php 9    php 99

php 99

By Jahnzaib

16

Recently Updated  

Product Image
Product Image
1/2

Product Description

Bilkul, bro! Chalo step by step check karte hain ke problem kaha ho sakti hai. Tum keh rahe ho:

Jab tum category pe click karte ho aur next page pe jatay ho, to tumhain sirf usi category ke related brands dikhne chahiye — lekin wo nahi ho raha.

Mujhe tumhara blade file ka code mila hai jahan pe brands list ho rahe hain, aur controller ka showBrands method bhi mil gaya hai. Let’s do some debugging.


βœ… Step 1: Category Click Link Check

Pehle ye confirm kar lein ke category pe click krne se sahi ID ja rahi hai ya nahi.

Blade file (category listing) me:


 

blade

CopyEdit

<a href="{{ route('show.brands', $category->id) }}">{{ $category->name }}</a>

Ye sahi lag raha hai. Is se route /show-brands/{id} call ho raha hai.


βœ… Step 2: Route Check

Route sahi bana hua hona chahiye:


 

php

CopyEdit

Route::get('/show-brands/{id}', [BrandController::class, 'showBrands'])->name('show.brands');

Yeh bhi perfect hai.


βœ… Step 3: Controller Logic

Controller me tumhara logic kuch is tarah hai:


 

php

CopyEdit

public function showBrands($id) { $category = Category::findOrFail($id); $brands = Brand::where('category_id', $id)->get(); return view('brands.show', compact('category', 'brands')); }

Yeh bhi sahi lag raha hai — lekin problems ho sakti hain agar:

1. Brand table me category_id empty ya galat ho

Check karo brands table me har brand ke andar category_id sahi saved hai ya nahi.


 

sql

CopyEdit

SELECT * FROM brands WHERE category_id = X;

Agar empty aata hai to where('category_id', $id) koi record return nahi karega.


βœ… Step 4: Database Relationship Check

Check karo Brand model me ye relation hai:


 

php

CopyEdit

public function category() { return $this->belongsTo(Category::class); }

Aur brands table me foreign key category_id hai.

$0.00
     Future Updates
     Quality checked by ASI coder
     Responsive
    $2.00
    Download

    Last Update

    April 18, 2025

    Published

    April 18, 2025

    Resolution Screen

    yes

    Included Files

    html | php | css | java

    Support Browsers

    chrome | google | sss

    Use FrameWork

    laravel | react

    Software Version

    php 11

    Tags

    asd | dsfewr | dfer | dsfr | ssss

Sign up for Newsletters

Be the first to know. Subscribe today and unlock exclusive deals!

888 345 6789

Free support line!

Support@posthemes.com

Orders Support!

Mon - Fri / 8:00 - 18:00

Working Days / Hours!