diff --git a/app/controllers/api/shops_controller.rb b/app/controllers/api/shops_controller.rb index 7c264f83..3d34959a 100644 --- a/app/controllers/api/shops_controller.rb +++ b/app/controllers/api/shops_controller.rb @@ -3,7 +3,9 @@ class Api::ShopsController < Api::ApiController skip_before_action :set_current_tenant_by_subdomain_or_name, only: [:index, :show] def index - @shops = Shop.select('id, logo, name, shop_code').where.not(cloud_url: nil).all + @shops = Shop.select('shops.id, logo, shops.name, shops.shop_code,image as cover') + .left_joins(:display_images) + .where.not(cloud_url: nil).order('shop_code,display_images.created_at desc').uniq end def show diff --git a/app/views/api/shops/index.json.jbuilder b/app/views/api/shops/index.json.jbuilder index 4836e68a..4c80b9c3 100644 --- a/app/views/api/shops/index.json.jbuilder +++ b/app/views/api/shops/index.json.jbuilder @@ -4,4 +4,4 @@ if @shops else json.status false json.message "Record Not Found" -end \ No newline at end of file +end