Categories
Programming Technology Web Development

Pagination in laravel relation

public function get_shop_products($shop_id)
{
$shop = Shop::query()
->where(‘id’ , $shop_id)
->first();
$shop->setRelation(‘products’ , $shop->products()->paginate(10));
return new ShopProductsResource($shop);
}

Masoud Hosseini

Leave a Reply

Your email address will not be published. Required fields are marked *