this is part of my UserResource.php in my Laravel app that returns info for the current…
- User
this is part of my UserResource.php in my Laravel app that returns info for the current user:
$userProducts = $this->productOrders() ->join('products', 'product_orders.product_id', '=', 'products.id') ->where('product_orders.status', 'Paid') ->whereNotNull('product_orders.product_id') ->with(['product.game']); $mpUserProducts = clone $userProducts; $userProducts = $userProducts->where('products.consumable', false); $userDisabledProducts = []; foreach ($userProducts->get() as $userProduct) { if ($userProduct->not_allowed_products) { $userDisabledProducts = array_merge($userDisabledProducts, json_decode($userProduct->not_allowed_products)); } } $data['disabled_products'] = array_map('intval', array_unique($userDisabledProducts)); $purchasedProducts = $userProducts->select('product_orders.product_id')->groupBy('product_id')->get(); $data['purchased_products'] = UserPurchasedProductsResource::collection($purchasedProducts)->toArray($request); $hasRemainingProducts = $userProducts->where('products.slug', '!=', 'game1') ->where(function ($query) { $query->where('product_orders.currency', '!=', 'DC') ->orWhereNull('product_orders.currency'); }) ->exists(); $mpHasRemainingProducts = $mpUserProducts->where('products.slug', '!=', 'game1') ->where(function ($query) { $query->where('product_orders.currency', '!=', 'DC') ->orWhereNull('product_orders.currency'); }) ->exists(); $data['has_purchased_products'] = $hasRemainingProducts; $data['mp_has_purchased_products'] = $mpHasRemainingProducts;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.