app/Http/Controllers/ProductController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $products = Product::where('user_id', '=', Auth::id())
                    ->latest()
                    ->with(['category' => function($thumb){
                        $thumb->select('id','category_name');
                    }])
                    ->with(['subcategory' => function($thumb){
                        $thumb->select('id','sub_category_name');
                    }])
                    ->paginate(5);
        return view('products.index',compact('products'))
            ->with('i', (request()->input('page', 1) - 1) * 5);
    }
public function index ( ) { $ products = Product :: where ( 'user_id' , '=' , Auth :: id ( ) ) -> latest ( ) -> with ( [ 'category' => function ( $ thumb ) { $ thumb -> select ( 'id' , 'category_name' ) ; } ] ) -> with ( [ 'subcategory' => function ( $ thumb ) { $ thumb -> select ( 'id' , 'sub_category_name' ) ; } ] ) -> paginate ( 5 ) ; return view ( 'products.index' , compact ( 'products' ) ) -> with ( 'i' , ( request ( ) -> input ( 'page' , 1 ) - 1 ) * 5 ) ; }
Display a listing of the resource.
Display a listing of the resource .