ErrorException
PHP 8.1.2910.48.9
Attempt to read property "sub_products" on null
app / Http / Controllers / FrontendController.php: 254
        }
        else{
            return view('frontend.pages.product-lists')->with('products',$products->products)->with('recent_products',$recent_products);
        }

    }
    public function productSubCat(Request $request){
        $products=Category::getProductBySubCat($request->sub_slug);
        // return $products;
        $recent_products=Product::where('status','active')->orderBy('id','DESC')->limit(3)->get();

        if(request()->is('e-shop.loc/product-grids')){
            return view('frontend.pages.product-grids')->with('products',$products->sub_products)->with('recent_products',$recent_products);
        }
        else{
            return view('frontend.pages.product-lists')->with('products',$products->sub_products)->with('recent_products',$recent_products);
        }

    }

    public function blog(){
        $post=Post::query();

        if(!empty($_GET['category'])){
            $slug=explode(',',$_GET['category']);
            // dd($slug);
            $cat_ids=PostCategory::select('id')->whereIn('slug',$slug)->pluck('id')->toArray();
            return $cat_ids;
            $post->whereIn('post_cat_id',$cat_ids);
            // return $post;

App

Routing

Controller
App\Http\Controllers\FrontendController@productSubCat
Route name
product-sub-cat
Middleware
  • web

Request

https://onlieaffiliate.com/product-sub-cat/home-appliances/privacy-policy
GET
curl "https://onlieaffiliate.com/product-sub-cat/home-appliances/privacy-policy" \
   -X GET \
   -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
   -H 'accept-encoding: gzip, deflate, br, zstd' \
   -H 'cache-control: no-cache' \
   -H 'connection: keep-alive' \
   -H 'host: onlieaffiliate.com' \
   -H 'pragma: no-cache' \
   -H 'sec-ch-ua: "HeadlessChrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"' \
   -H 'sec-ch-ua-mobile: ?0' \
   -H 'sec-ch-ua-platform: "Windows"' \
   -H 'sec-fetch-dest: document' \
   -H 'sec-fetch-mode: navigate' \
   -H 'sec-fetch-site: none' \
   -H 'sec-fetch-user: ?1' \
   -H 'upgrade-insecure-requests: 1' \
   -H 'user-agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)' \
   -H 'x-https: 1';

Browser

Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

Headers

accept
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
accept-encoding
gzip, deflate, br, zstd
cache-control
no-cache
connection
keep-alive
host
onlieaffiliate.com
pragma
no-cache
sec-ch-ua
"HeadlessChrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"
sec-ch-ua-mobile
?0
sec-ch-ua-platform
"Windows"
sec-fetch-dest
document
sec-fetch-mode
navigate
sec-fetch-site
none
sec-fetch-user
?1
upgrade-insecure-requests
1
user-agent
Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
x-https
1

Body

[]

Context

Versions

Php Version
8.1.29
Laravel Version
10.48.9
Laravel Locale
en
Laravel Config Cached
false
App Debug
true
App Env
production
10:46:53 AM
Runtime 2.44ms
Connection mysql
select * from `categories` where `slug` = privacy-policy limit 1
10:46:53 AM
Runtime 1.28ms
Connection mysql
select * from `products` where `status` = active order by `id` desc limit 3