Without code we can only guess. Maybe you have this, but no user is signed in
Auth::user()->id
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
what is the solution for this problem .. thanks in advance
Without code we can only guess. Maybe you have this, but no user is signed in
Auth::user()->id
@Sinnbeck what is the solution for this problem .. thanks in advance
@Michael Fayez the solution is to share the exception stacktrace and/or the relevant code
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Category;
use App\Models\SubCategory;
use App\Models\MultiImg;
use App\Models\Brand;
use App\Models\Product;
use App\Models\User;
class IndexController extends Controller
{
public function Index(){
$skip_category_0 = Category::skip(0)->first();
$skip_product_0 = Product::where('status',1)->where('category_id',$skip_category_0->id)->orderBy('id','DESC')->limit(5)->get();
$skip_category_2 = Category::skip(2)->first();
$skip_product_2 = Product::where('status',1)->where('category_id',$skip_category_2->id)->orderBy('id','DESC')->limit(5)->get();
$skip_category_7 = Category::skip(7)->first();
$skip_product_7 = Product::where('status',1)->where('category_id',$skip_category_7->id)->orderBy('id','DESC')->limit(5)->get();
$hot_deals = Product::where('hot_deals',1)->where('discount_price','!=',NULL)->orderBy('id','DESC')->limit(3)->get();
$special_offer = Product::where('special_offer',1)->orderBy('id','DESC')->limit(3)->get();
$new = Product::where('status',1)->orderBy('id','DESC')->limit(3)->get();
$special_deals = Product::where('special_deals',1)->orderBy('id','DESC')->limit(3)->get();
return view('frontend.index',compact('skip_category_0','skip_product_0','skip_category_2','skip_product_2','skip_category_7','skip_product_7','hot_deals','special_offer','new','special_deals'));
}```
Finally I made the code :)
@tykus ```<?php
namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller; use Illuminate\Http\Request; use App\Models\Category; use App\Models\SubCategory; use App\Models\MultiImg; use App\Models\Brand; use App\Models\Product; use App\Models\User;
class IndexController extends Controller {
public function Index(){
$skip_category_0 = Category::skip(0)->first();
$skip_product_0 = Product::where('status',1)->where('category_id',$skip_category_0->id)->orderBy('id','DESC')->limit(5)->get();
$skip_category_2 = Category::skip(2)->first();
$skip_product_2 = Product::where('status',1)->where('category_id',$skip_category_2->id)->orderBy('id','DESC')->limit(5)->get();
$skip_category_7 = Category::skip(7)->first();
$skip_product_7 = Product::where('status',1)->where('category_id',$skip_category_7->id)->orderBy('id','DESC')->limit(5)->get();
$hot_deals = Product::where('hot_deals',1)->where('discount_price','!=',NULL)->orderBy('id','DESC')->limit(3)->get();
$special_offer = Product::where('special_offer',1)->orderBy('id','DESC')->limit(3)->get();
$new = Product::where('status',1)->orderBy('id','DESC')->limit(3)->get();
$special_deals = Product::where('special_deals',1)->orderBy('id','DESC')->limit(3)->get();
return view('frontend.index',compact('skip_category_0','skip_product_0','skip_category_2','skip_product_2','skip_category_7','skip_product_7','hot_deals','special_offer','new','special_deals'));
}```
@michael fayez sounds like one of those $skip_category variables is null. You should be able to find the problem one from the stack trace.
@michael fayez these will be null if the there are no matching records
$skip_category_0 = Category::skip(0)->first();
$skip_category_2 = Category::skip(2)->first();
$skip_category_7 = Category::skip(7)->first();
You should do something in mitigation...
Please or to participate in this conversation.