select(['id', 'name', 'plat_id']) ->with('ship') ->where('plat_id', 1) ->get(); $time = time(); foreach ($shops as $shop) { $faceSheet = new FaceSheet(); $shop->authUrl = $faceSheet->getAuthUrl($shop->id, $shop->plat_id); $shop->status = 0; if ($shop->ship) { $shop->status = $shop->ship->getOriginal('status'); if ($shop->ship->expires_at && $time >= $shop->ship->expires_at) { ShopShip::query()->where('shop_id', $shop->id)->update(['status' => Shop::$STATUS_UNAUTHORIZED]); } } } return ShopsResource::collection($shops); } }