File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,13 @@ class ProductController extends Controller
1212 // We want category object also so that's why we have created the relationship
1313 // So our query will be use `with()` which help us to return the relationship too.
1414 public function index () {
15- $ products = Product::with ('category ' )->get ();
15+ /**
16+ * In Traditional way we use this approach to generate pagination links.
17+ * $products = Product::with('category')->paginate(9);
18+ * After that we use interpolate syntax in blade file to render pagination links. { $products->link }
19+ * API approach is similar to like this one.
20+ */
21+ $ products = Product::with ('category ' )->paginate (9 );
1622 // return $products;
1723 return ProductResource::collection ($ products );
1824 }
You can’t perform that action at this time.
0 commit comments