output:
Chunk ID: e18793
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 5164
Output:
tests/Feature/Admin/ProductMediaManagementTest.php:42:    Livewire::actingAs($user)
tests/Feature/Admin/ProductMediaManagementTest.php:77:    Livewire::actingAs($user)
tests/Feature/Admin/ProductMediaManagementTest.php:112:    Livewire::actingAs($user)
tests/Feature/Admin/ProductMediaManagementTest.php:147:    $component = Livewire::actingAs($user)
tests/Feature/Admin/AppsDevelopersTest.php:6:use App\Models\OauthToken;
tests/Feature/Admin/AppsDevelopersTest.php:45:    $this->actingAs(appsDevelopersUser(StoreUserRole::Admin))
tests/Feature/Admin/AppsDevelopersTest.php:53:    $this->actingAs(appsDevelopersUser(StoreUserRole::Staff))
tests/Feature/Admin/AppsDevelopersTest.php:63:    $initialTokenCount = OauthToken::query()
tests/Feature/Admin/AppsDevelopersTest.php:67:    Livewire::actingAs($user)
tests/Feature/Admin/AppsDevelopersTest.php:81:    expect(OauthToken::query()
tests/Feature/Admin/CustomerManagementTest.php:71:    $this->actingAs(adminCustomerManagementUser())
tests/Feature/Admin/CustomerManagementTest.php:79:    $this->actingAs(adminCustomerManagementUser())
tests/Feature/Admin/CustomerManagementTest.php:87:    $this->actingAs(adminCustomerManagementUser())
tests/Feature/Admin/CustomerManagementTest.php:99:    Livewire::actingAs($user)
tests/Feature/Admin/CustomerManagementTest.php:120:    Livewire::actingAs($user)
tests/Feature/Admin/CustomerManagementTest.php:138:    Livewire::actingAs($user)
tests/Feature/Admin/CustomerManagementTest.php:161:    Livewire::actingAs(adminCustomerManagementUser())
tests/Feature/Admin/SettingsManagementTest.php:59:        $this->actingAs($owner)
tests/Feature/Admin/SettingsManagementTest.php:64:        $this->actingAs($staff)
tests/Feature/Admin/SettingsManagementTest.php:75:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:105:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:117:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:143:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:176:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:207:    Livewire::actingAs($user)
tests/Feature/Admin/SettingsManagementTest.php:224:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:76:    $this->actingAs(adminDiscountManagementUser())
tests/Feature/Admin/DiscountManagementTest.php:85:    $this->actingAs(adminDiscountManagementUser())
tests/Feature/Admin/DiscountManagementTest.php:91:    $this->actingAs(adminDiscountManagementUser())
tests/Feature/Admin/DiscountManagementTest.php:130:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:157:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:194:    $this->actingAs($supportUser)
tests/Feature/Admin/DiscountManagementTest.php:199:    $this->actingAs($supportUser)
tests/Feature/Admin/DiscountManagementTest.php:204:    $this->actingAs($unverifiedUser)
tests/Feature/Admin/DiscountManagementTest.php:209:    Livewire::actingAs($supportUser)
tests/Feature/Admin/DiscountManagementTest.php:222:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:230:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:243:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:254:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:266:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:290:    Livewire::actingAs($user)
tests/Feature/Admin/DiscountManagementTest.php:303:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:66:    $this->actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:73:    $this->actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:79:    $this->actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:85:    $this->actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:91:    $this->actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:102:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:119:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:125:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:135:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:151:    $component = Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:206:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:221:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:242:    Livewire::actingAs($user)
tests/Feature/Admin/ContentManagementTest.php:266:    Livewire::actingAs($support)
tests/Feature/Admin/ContentManagementTest.php:270:    Livewire::actingAs($staff)
tests/Feature/Admin/ContentManagementTest.php:274:    Livewire::actingAs($staff)
tests/Feature/Admin/ContentManagementTest.php:278:    Livewire::actingAs(adminContentUser())
tests/Feature/Admin/ContentManagementTest.php:282:    Livewire::actingAs(adminContentUser())
tests/Feature/Admin/SearchSettingsTest.php:32:    $this->actingAs(adminSearchSettingsUser())
tests/Feature/Admin/SearchSettingsTest.php:43:    Livewire::actingAs(adminSearchSettingsUser())
tests/Feature/Admin/SearchSettingsTest.php:74:    Livewire::actingAs(adminSearchSettingsUser())
tests/Feature/Admin/OrderManagementTest.php:111:    $this->actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:117:    $this->actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:139:    Livewire::actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:165:    Livewire::actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:184:    Livewire::actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:194:    Livewire::actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:207:    Livewire::actingAs($user)
tests/Feature/Admin/OrderManagementTest.php:227:    Livewire::actingAs($user)
tests/Feature/Admin/AnalyticsDashboardTest.php:42:    $this->actingAs(adminAnalyticsUser(StoreUserRole::Staff))
tests/Feature/Admin/AnalyticsDashboardTest.php:52:    $this->actingAs(adminAnalyticsUser(StoreUserRole::Support))
tests/Feature/Admin/AnalyticsDashboardTest.php:61:    Livewire::actingAs(adminAnalyticsUser(StoreUserRole::Admin))
tests/Feature/Admin/DashboardTest.php:93:    $this->actingAs(adminDashboardUser())
tests/Feature/Admin/DashboardTest.php:112:    Livewire::actingAs($user)
tests/Feature/Api/AdminSearchIndexApiTest.php:32: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminSearchIndexApiTest.php:53:    $this->actingAs(adminSearchIndexApiUser())
tests/Feature/Api/AdminSearchIndexApiTest.php:59:    $this->actingAs(adminSearchIndexApiUser())
tests/Feature/Api/AdminSearchIndexApiTest.php:68:    $this->actingAs(adminSearchIndexApiUser())
tests/Feature/Api/AdminSearchIndexApiTest.php:82:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminSearchIndexApiTest.php:86:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminSearchIndexApiTest.php:90:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminSearchIndexApiTest.php:94:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:47: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:106:    $this->actingAs(adminAnalyticsSummaryApiUser())
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:136:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:140:    $this->withToken($wrongAbilityToken['plain_text'])
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:144:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:152:    $this->actingAs(adminAnalyticsSummaryApiUser())
tests/Feature/Api/AdminAnalyticsSummaryApiTest.php:157:    $this->actingAs(adminAnalyticsSummaryApiUser())
app/Models/OauthToken.php:9:class OauthToken extends Model
app/Models/OauthToken.php:11:    /** @use HasFactory<\Database\Factories\OauthTokenFactory> */
tests/Feature/Api/AdminStoreSettingsApiTest.php:29: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminStoreSettingsApiTest.php:40:    $this->actingAs($user)
tests/Feature/Api/AdminStoreSettingsApiTest.php:48:    $this->actingAs($user)
tests/Feature/Api/AdminStoreSettingsApiTest.php:91:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminStoreSettingsApiTest.php:95:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminStoreSettingsApiTest.php:101:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminStoreSettingsApiTest.php:105:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminStoreSettingsApiTest.php:120:    $this->actingAs(adminStoreSettingsApiUser())
tests/Feature/Api/AdminStoreSettingsApiTest.php:129:    $this->actingAs(adminStoreSettingsApiUser())
tests/Feature/Api/AdminStoreSettingsApiTest.php:136:    $this->actingAs(adminStoreSettingsApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:37: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminCatalogApiTest.php:39:function adminCatalogApiToken(Store $store, array $abilities): array
tests/Feature/Api/AdminCatalogApiTest.php:68:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:76:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:93:    $createResponse = $this->actingAs($user)
tests/Feature/Api/AdminCatalogApiTest.php:162:    $this->actingAs($user)
tests/Feature/Api/AdminCatalogApiTest.php:190:    $this->actingAs($user)
tests/Feature/Api/AdminCatalogApiTest.php:205:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:246:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:254:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:272:    $productToken = adminCatalogApiToken($store, ['read-products']);
tests/Feature/Api/AdminCatalogApiTest.php:273:    $writeProductToken = adminCatalogApiToken($store, ['write-products']);
tests/Feature/Api/AdminCatalogApiTest.php:274:    $customerToken = adminCatalogApiToken($store, ['read-customers']);
tests/Feature/Api/AdminCatalogApiTest.php:276:    $this->withToken($productToken['plain_text'])
tests/Feature/Api/AdminCatalogApiTest.php:281:    $this->withToken($productToken['plain_text'])
tests/Feature/Api/AdminCatalogApiTest.php:285:    $this->withToken($productToken['plain_text'])
tests/Feature/Api/AdminCatalogApiTest.php:298:    $this->withToken($writeProductToken['plain_text'])
tests/Feature/Api/AdminCatalogApiTest.php:312:    $this->withToken($customerToken['plain_text'])
tests/Feature/Api/AdminCatalogApiTest.php:328:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:332:    $this->actingAs(adminCatalogApiUser())
tests/Feature/Api/AdminCatalogApiTest.php:340:    $this->actingAs(adminCatalogApiUser())
app/Http/Controllers/Api/Admin/V1/StoreMembershipController.php:6:use App\Models\OauthToken;
app/Http/Controllers/Api/Admin/V1/StoreMembershipController.php:18:        if ($token instanceof OauthToken) {
tests/Feature/Api/AdminPlatformApiTest.php:30: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminPlatformApiTest.php:32:function adminPlatformApiToken(Store $store, array $abilities): array
tests/Feature/Api/AdminPlatformApiTest.php:40:    $organizationResponse = $this->actingAs($user)
tests/Feature/Api/AdminPlatformApiTest.php:51:    $this->actingAs($user)
tests/Feature/Api/AdminPlatformApiTest.php:86:    $readToken = adminPlatformApiToken($store, ['read-products']);
tests/Feature/Api/AdminPlatformApiTest.php:88:    $this->actingAs($staff)
tests/Feature/Api/AdminPlatformApiTest.php:95:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminPlatformApiTest.php:105:    $token = adminPlatformApiToken($store, ['manage-platform']);
tests/Feature/Api/AdminPlatformApiTest.php:107:    $this->withToken($token['plain_text'])
tests/Feature/Api/AdminPlatformApiTest.php:130:    $readToken = adminPlatformApiToken($store, ['read-products']);
tests/Feature/Api/AdminPlatformApiTest.php:131:    $manageToken = adminPlatformApiToken($store, ['manage-platform']);
tests/Feature/Api/AdminPlatformApiTest.php:133:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminPlatformApiTest.php:140:    $this->withToken($manageToken['plain_text'])
tests/Feature/Api/AdminPlatformApiTest.php:149:    $this->actingAs($user)
tests/Feature/Api/AdminPlatformApiTest.php:156:    $this->actingAs($staff)
tests/Feature/Api/AdminPlatformApiTest.php:163:    $this->actingAs($user)
tests/Feature/Api/AdminShippingSettingsApiTest.php:31: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminShippingSettingsApiTest.php:42:    $this->actingAs($user)
tests/Feature/Api/AdminShippingSettingsApiTest.php:48:    $createResponse = $this->actingAs($user)
tests/Feature/Api/AdminShippingSettingsApiTest.php:61:    $this->actingAs($user)
tests/Feature/Api/AdminShippingSettingsApiTest.php:71:    $rateResponse = $this->actingAs($user)
tests/Feature/Api/AdminShippingSettingsApiTest.php:101:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminShippingSettingsApiTest.php:105:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminShippingSettingsApiTest.php:112:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminShippingSettingsApiTest.php:116:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminShippingSettingsApiTest.php:131:    $this->actingAs(adminShippingSettingsApiUser())
tests/Feature/Api/AdminShippingSettingsApiTest.php:139:    $this->actingAs(adminShippingSettingsApiUser())
tests/Feature/Api/AdminCollectionApiTest.php:30: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminCollectionApiTest.php:49:    $this->actingAs($user)
tests/Feature/Api/AdminCollectionApiTest.php:54:    $createResponse = $this->actingAs($user)
tests/Feature/Api/AdminCollectionApiTest.php:76:    $this->actingAs($user)
tests/Feature/Api/AdminCollectionApiTest.php:91:    $this->actingAs($user)
tests/Feature/Api/AdminCollectionApiTest.php:110:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminCollectionApiTest.php:115:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminCollectionApiTest.php:119:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminCollectionApiTest.php:123:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminCollectionApiTest.php:138:    $this->actingAs(adminCollectionApiUser())
tests/Feature/Api/AdminDiscountApiTest.php:32: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminDiscountApiTest.php:45:    $this->actingAs($user)
tests/Feature/Api/AdminDiscountApiTest.php:49:    $createResponse = $this->actingAs($user)
tests/Feature/Api/AdminDiscountApiTest.php:76:    $this->actingAs($user)
tests/Feature/Api/AdminDiscountApiTest.php:88:    $this->actingAs($user)
tests/Feature/Api/AdminDiscountApiTest.php:107:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminDiscountApiTest.php:112:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminDiscountApiTest.php:116:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminDiscountApiTest.php:120:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminDiscountApiTest.php:135:    $this->actingAs(adminDiscountApiUser())
tests/Feature/Api/AdminThemeApiTest.php:34: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminThemeApiTest.php:108:    $response = $this->actingAs($user)
tests/Feature/Api/AdminThemeApiTest.php:132:    $this->actingAs(adminThemeApiUser())
tests/Feature/Api/AdminThemeApiTest.php:145:    $this->actingAs(adminThemeApiUser())
tests/Feature/Api/AdminThemeApiTest.php:164:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminThemeApiTest.php:168:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminThemeApiTest.php:172:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminThemeApiTest.php:191:    $this->actingAs(adminThemeApiUser())
tests/Feature/Api/AdminThemeApiTest.php:200:    $this->actingAs(adminThemeApiUser())
tests/Feature/Api/AdminThemeApiTest.php:207:    $this->actingAs(adminThemeApiUser())
app/Models/AppInstallation.php:55:     * @return HasMany<OauthToken, $this>
app/Models/AppInstallation.php:59:        return $this->hasMany(OauthToken::class, 'installation_id');
tests/Feature/Api/AdminOrderExportApiTest.php:33: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminOrderExportApiTest.php:78:    $createResponse = $this->actingAs(adminOrderExportApiUser())
tests/Feature/Api/AdminOrderExportApiTest.php:94:    $showResponse = $this->actingAs(adminOrderExportApiUser())
tests/Feature/Api/AdminOrderExportApiTest.php:120:    $this->withToken($wrongAbilityToken['plain_text'])
tests/Feature/Api/AdminOrderExportApiTest.php:126:    $createResponse = $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminOrderExportApiTest.php:134:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminOrderExportApiTest.php:138:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminOrderExportApiTest.php:146:    $this->actingAs(adminOrderExportApiUser())
tests/Feature/Api/AdminOrderExportApiTest.php:154:    $this->actingAs(adminOrderExportApiUser())
tests/Feature/Api/AdminOrderApiTest.php:38: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminOrderApiTest.php:109:    $this->actingAs(adminOrderApiUser())
tests/Feature/Api/AdminOrderApiTest.php:115:    $this->actingAs(adminOrderApiUser())
tests/Feature/Api/AdminOrderApiTest.php:127:    $this->actingAs($user)
tests/Feature/Api/AdminOrderApiTest.php:138:    $this->actingAs($user)
tests/Feature/Api/AdminOrderApiTest.php:163:    $this->actingAs(adminOrderApiUser())
tests/Feature/Api/AdminOrderApiTest.php:176:    $this->withToken($result['plain_text'])
tests/Feature/Api/AdminOrderApiTest.php:192:    $this->withToken($readOnly['plain_text'])
tests/Feature/Api/AdminOrderApiTest.php:199:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminOrderApiTest.php:203:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminOrderApiTest.php:218:    $this->withToken($result['plain_text'])
tests/Feature/Api/AdminPageApiTest.php:29: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminPageApiTest.php:51:    $this->actingAs($user)
tests/Feature/Api/AdminPageApiTest.php:57:    $createResponse = $this->actingAs($user)
tests/Feature/Api/AdminPageApiTest.php:72:    $this->actingAs($user)
tests/Feature/Api/AdminPageApiTest.php:83:    $this->actingAs($user)
tests/Feature/Api/AdminPageApiTest.php:103:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminPageApiTest.php:108:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminPageApiTest.php:112:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminPageApiTest.php:116:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminPageApiTest.php:128:    $this->actingAs(adminPageApiUser())
tests/Feature/Api/AdminPageApiTest.php:137:    $this->actingAs(adminPageApiUser())
tests/Feature/Api/AdminTaxSettingsApiTest.php:30: * @return array{token: \App\Models\OauthToken, plain_text: string}
tests/Feature/Api/AdminTaxSettingsApiTest.php:41:    $this->actingAs($user)
tests/Feature/Api/AdminTaxSettingsApiTest.php:48:    $this->actingAs($user)
tests/Feature/Api/AdminTaxSettingsApiTest.php:86:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminTaxSettingsApiTest.php:90:    $this->withToken($readToken['plain_text'])
tests/Feature/Api/AdminTaxSettingsApiTest.php:99:    $this->withToken($otherStoreToken['plain_text'])
tests/Feature/Api/AdminTaxSettingsApiTest.php:103:    $this->withToken($writeToken['plain_text'])
tests/Feature/Api/AdminTaxSettingsApiTest.php:120:    $this->actingAs(adminTaxSettingsApiUser())
tests/Feature/Api/AdminTaxSettingsApiTest.php:129:    $this->actingAs(adminTaxSettingsApiUser())


output:
Chunk ID: 60d642
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 3117
Output:
<?php

use App\Http\Controllers\Api\Admin\V1\AnalyticsSummaryController as AdminAnalyticsSummaryController;
use App\Http\Controllers\Api\Admin\V1\CollectionController as AdminCollectionController;
use App\Http\Controllers\Api\Admin\V1\CustomerController as AdminCustomerController;
use App\Http\Controllers\Api\Admin\V1\DiscountController as AdminDiscountController;
use App\Http\Controllers\Api\Admin\V1\OrderController as AdminOrderController;
use App\Http\Controllers\Api\Admin\V1\OrderExportController as AdminOrderExportController;
use App\Http\Controllers\Api\Admin\V1\OrderFulfillmentController as AdminOrderFulfillmentController;
use App\Http\Controllers\Api\Admin\V1\OrderRefundController as AdminOrderRefundController;
use App\Http\Controllers\Api\Admin\V1\PageController as AdminPageController;
use App\Http\Controllers\Api\Admin\V1\PlatformOrganizationController as AdminPlatformOrganizationController;
use App\Http\Controllers\Api\Admin\V1\PlatformStoreController as AdminPlatformStoreController;
use App\Http\Controllers\Api\Admin\V1\ProductController as AdminProductController;
use App\Http\Controllers\Api\Admin\V1\SearchIndexController as AdminSearchIndexController;
use App\Http\Controllers\Api\Admin\V1\ShippingRateController as AdminShippingRateController;
use App\Http\Controllers\Api\Admin\V1\ShippingZoneController as AdminShippingZoneController;
use App\Http\Controllers\Api\Admin\V1\StoreInviteController as AdminStoreInviteController;
use App\Http\Controllers\Api\Admin\V1\StoreMembershipController as AdminStoreMembershipController;
use App\Http\Controllers\Api\Admin\V1\StoreSettingsController as AdminStoreSettingsController;
use App\Http\Controllers\Api\Admin\V1\TaxSettingsController as AdminTaxSettingsController;
use App\Http\Controllers\Api\Admin\V1\ThemeController as AdminThemeController;
use App\Http\Controllers\Api\Admin\V1\ThemeSettingsController as AdminThemeSettingsController;
use App\Http\Controllers\Api\Apps\V1\DeferredEndpointController as DeferredAppEndpointController;
use App\Http\Controllers\Api\Storefront\V1\AnalyticsEventController as StorefrontAnalyticsEventController;
use App\Http\Controllers\Api\Storefront\V1\CartController;
use App\Http\Controllers\Api\Storefront\V1\CartLineController;
use App\Http\Controllers\Api\Storefront\V1\CheckoutController;
use App\Http\Controllers\Api\Storefront\V1\OrderController as StorefrontOrderController;
use App\Http\Controllers\Api\Storefront\V1\SearchController as StorefrontSearchController;
use Illuminate\Support\Facades\Route;

Route::middleware('store.resolve')
    ->prefix('storefront/v1')
    ->name('api.storefront.v1.')
    ->group(function (): void {
        Route::middleware('throttle:api.storefront')->group(function (): void {
            Route::post('carts', [CartController::class, 'store'])->name('carts.store');
            Route::get('carts/{cart}', [CartController::class, 'show'])->name('carts.show');
            Route::post('carts/{cart}/lines', [CartLineController::class, 'store'])->name('carts.lines.store');
            Route::put('carts/{cart}/lines/{cartLine}', [CartLineController::class, 'update'])->name('carts.lines.update');
            Route::delete('carts/{cart}/lines/{cartLine}', [CartLineController::class, 'destroy'])->name('carts.lines.destroy');
        });

        Route::middleware('throttle:search')->group(function (): void {
            Route::get('search', [StorefrontSearchController::class, 'index'])->name('search.index');
            Route::get('search/suggest', [StorefrontSearchController::class, 'suggest'])->name('search.suggest');
        });

        Route::middleware('throttle:analytics')->group(function (): void {
            Route::post('analytics/events', [StorefrontAnalyticsEventController::class, 'store'])->name('analytics.events.store');
        });

        Route::middleware('throttle:checkout')->group(function (): void {
            Route::post('checkouts', [CheckoutController::class, 'store'])->name('checkouts.store');
            Route::get('checkouts/{checkout}', [CheckoutController::class, 'show'])->name('checkouts.show');
            Route::put('checkouts/{checkout}/address', [CheckoutController::class, 'address'])->name('checkouts.address');
            Route::put('checkouts/{checkout}/shipping-method', [CheckoutController::class, 'shippingMethod'])->name('checkouts.shipping-method');
            Route::post('checkouts/{checkout}/apply-discount', [CheckoutController::class, 'applyDiscount'])->name('checkouts.apply-discount');
            Route::delete('checkouts/{checkout}/discount', [CheckoutController::class, 'destroyDiscount'])->name('checkouts.discount.destroy');
            Route::put('checkouts/{checkout}/payment-method', [CheckoutController::class, 'paymentMethod'])->name('checkouts.payment-method');
            Route::post('checkouts/{checkout}/pay', [CheckoutController::class, 'pay'])->name('checkouts.pay');
            Route::get('orders/{orderNumber}', [StorefrontOrderController::class, 'show'])->name('orders.show');
        });
    });

Route::middleware('throttle:60,1')
    ->prefix('admin/v1/platform')
    ->name('api.admin.v1.platform.')
    ->middleware(['auth:sanctum', 'platform.api'])
    ->group(function (): void {
        Route::post('organizations', [AdminPlatformOrganizationController::class, 'store'])->name('organizations.store');
        Route::post('stores', [AdminPlatformStoreController::class, 'store'])->name('stores.store');
    });

Route::middleware('throttle:60,1')
    ->prefix('admin/v1/stores/{store}')
    ->name('api.admin.v1.')
    ->middleware('auth:sanctum')
    ->group(function (): void {
        Route::middleware('admin.api')->group(function (): void {
            Route::get('me', [AdminStoreMembershipController::class, 'show'])->name('stores.me');
        });

        Route::middleware('admin.api:manage-platform')->group(function (): void {
            Route::post('invites', [AdminStoreInviteController::class, 'store'])->name('stores.invites.store');
        });

        Route::middleware('admin.api:read-products')->group(function (): void {
            Route::get('products', [AdminProductController::class, 'index'])->name('products.index');
            Route::get('products/{product}', [AdminProductController::class, 'show'])->name('products.show');
        });

        Route::middleware('admin.api:write-products')->group(function (): void {
            Route::post('products', [AdminProductController::class, 'store'])->name('products.store');
            Route::put('products/{product}', [AdminProductController::class, 'update'])->name('products.update');
            Route::delete('products/{product}', [AdminProductController::class, 'destroy'])->name('products.destroy');
            Route::post('products/{product}/media/presign-upload', [AdminProductController::class, 'presignUpload'])->name('products.media.presign-upload');
        });

        Route::middleware('admin.api:read-customers')->group(function (): void {
            Route::get('customers', [AdminCustomerController::class, 'index'])->name('customers.index');
            Route::get('customers/{customer}', [AdminCustomerController::class, 'show'])->name('customers.show');
        });

        Route::middleware('admin.api:read-collections')->group(function (): void {
            Route::get('collections', [AdminCollectionController::class, 'index'])->name('collections.index');
        });

        Route::middleware('admin.api:write-collections')->group(function (): void {
            Route::post('collections', [AdminCollectionController::class, 'store'])->name('collections.store');
            Route::put('collections/{collection}', [AdminCollectionController::class, 'update'])->name('collections.update');
            Route::delete('collections/{collection}', [AdminCollectionController::class, 'destroy'])->name('collections.destroy');
        });

        Route::middleware('admin.api:read-discounts')->group(function (): void {
            Route::get('discounts', [AdminDiscountController::class, 'index'])->name('discounts.index');
        });

        Route::middleware('admin.api:write-discounts')->group(function (): void {
            Route::post('discounts', [AdminDiscountController::class, 'store'])->name('discounts.store');
            Route::put('discounts/{discount}', [AdminDiscountController::class, 'update'])->name('discounts.update');
            Route::delete('discounts/{discount}', [AdminDiscountController::class, 'destroy'])->name('discounts.destroy');
        });

        Route::middleware('admin.api:read-content')->group(function (): void {
            Route::get('pages', [AdminPageController::class, 'index'])->name('pages.index');
        });

        Route::middleware('admin.api:write-content')->group(function (): void {
            Route::post('pages', [AdminPageController::class, 'store'])->name('pages.store');
            Route::put('pages/{page}', [AdminPageController::class, 'update'])->name('pages.update');
            Route::delete('pages/{page}', [AdminPageController::class, 'destroy'])->name('pages.destroy');
        });

        Route::middleware('admin.api:read-settings')->group(function (): void {
            Route::get('search/status', [AdminSearchIndexController::class, 'status'])->name('search.status');
            Route::get('settings', [AdminStoreSettingsController::class, 'show'])->name('settings.show');
            Route::get('shipping/zones', [AdminShippingZoneController::class, 'index'])->name('shipping.zones.index');
            Route::get('tax/settings', [AdminTaxSettingsController::class, 'show'])->name('tax.settings.show');
        });

        Route::middleware('admin.api:write-settings')->group(function (): void {
            Route::post('search/reindex', [AdminSearchIndexController::class, 'reindex'])->name('search.reindex');
            Route::put('settings', [AdminStoreSettingsController::class, 'update'])->name('settings.update');
            Route::post('shipping/zones', [AdminShippingZoneController::class, 'store'])->name('shipping.zones.store');
            Route::put('shipping/zones/{shippingZone}', [AdminShippingZoneController::class, 'update'])->name('shipping.zones.update');
            Route::post('shipping/zones/{shippingZone}/rates', [AdminShippingRateController::class, 'store'])->name('shipping.zones.rates.store');
            Route::put('tax/settings', [AdminTaxSettingsController::class, 'update'])->name('tax.settings.update');
        });

        Route::middleware('admin.api:write-themes')->group(function (): void {
            Route::post('themes', [AdminThemeController::class, 'store'])->name('themes.store');
            Route::post('themes/{theme}/publish', [AdminThemeController::class, 'publish'])->name('themes.publish');
            Route::put('themes/{theme}/settings', [AdminThemeSettingsController::class, 'update'])->name('themes.settings.update');
        });

        Route::middleware('admin.api:read-analytics')->group(function (): void {
            Route::get('analytics/summary', [AdminAnalyticsSummaryController::class, 'show'])->name('analytics.summary');
        });

        Route::middleware('admin.api:read-orders')->group(function (): void {
            Route::post('exports/orders', [AdminOrderExportController::class, 'store'])->name('exports.orders.store');
            Route::get('exports/{dataExport}', [AdminOrderExportController::class, 'show'])->name('exports.show');
            Route::get('orders', [AdminOrderController::class, 'index'])->name('orders.index');
            Route::get('orders/{order}', [AdminOrderController::class, 'show'])->name('orders.show');
        });

        Route::middleware('admin.api:write-orders')->group(function (): void {
            Route::post('orders/{order}/fulfillments', [AdminOrderFulfillmentController::class, 'store'])->name('orders.fulfillments.store');
            Route::post('orders/{order}/refunds', [AdminOrderRefundController::class, 'store'])->name('orders.refunds.store');
        });
    });

Route::middleware('throttle:60,1')
    ->prefix('apps/v1/stores/{store}')
    ->name('api.apps.v1.')
    ->group(function (): void {
        Route::get('products', DeferredAppEndpointController::class)->name('products.index');
        Route::get('orders', DeferredAppEndpointController::class)->name('orders.index');
        Route::get('customers', DeferredAppEndpointController::class)->name('customers.index');
    });


output:
Chunk ID: ac036c
Wall time: 0.0000 seconds
Process exited with code 1
Original token count: 21
Output:
sed: app/Http/Requests/Api/Admin/StoreProductRequest.php: No such file or directory


output:
Chunk ID: 4ce6ce
Wall time: 0.0000 seconds
Process exited with code 1
Original token count: 22
Output:
sed: app/Http/Requests/Api/Admin/UpdateProductRequest.php: No such file or directory


output:
Chunk ID: 643722
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1046
Output:
app/Http/Controllers/Api/Admin/V1/PageController.php:97:    private function authorizeStore(Request $request, Store $store): void
app/Http/Requests/Api/Admin/V1/StoreProductRequest.php:12:class StoreProductRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/StoreProductRequest.php:14:    public function authorize(): bool
app/Http/Controllers/Api/Admin/V1/ThemeController.php:65:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/OrderRefundController.php:43:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/ThemeSettingsController.php:44:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/ShippingZoneController.php:58:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/StoreSettingsController.php:88:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/TaxSettingsController.php:57:    private function authorizeStore(Request $request, Store $store): void
app/Http/Requests/Api/Admin/V1/CreateProductMediaUploadRequest.php:9:class CreateProductMediaUploadRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/CreateProductMediaUploadRequest.php:11:    public function authorize(): bool
app/Http/Requests/Api/Admin/V1/CreateOrderRefundRequest.php:7:class CreateOrderRefundRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/CreateOrderRefundRequest.php:9:    public function authorize(): bool
app/Http/Controllers/Api/Admin/V1/DiscountController.php:75:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/OrderFulfillmentController.php:37:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/ProductController.php:219:    private function authorizeStore(Request $request, Store $store): void
app/Http/Requests/Api/Admin/V1/StoreInviteRequest.php:8:class StoreInviteRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/StoreInviteRequest.php:10:    public function authorize(): bool
app/Http/Requests/Api/Admin/V1/CreateOrderFulfillmentRequest.php:7:class CreateOrderFulfillmentRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/CreateOrderFulfillmentRequest.php:9:    public function authorize(): bool
app/Http/Requests/Api/Admin/V1/StorePlatformStoreRequest.php:8:class StorePlatformStoreRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/StorePlatformStoreRequest.php:10:    public function authorize(): bool
app/Http/Controllers/Api/Admin/V1/CustomerController.php:54:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/OrderController.php:60:    private function authorizeStore(Request $request, Store $store): void
app/Http/Requests/Api/Admin/V1/StorePlatformOrganizationRequest.php:7:class StorePlatformOrganizationRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/StorePlatformOrganizationRequest.php:9:    public function authorize(): bool
app/Http/Controllers/Api/Admin/V1/OrderExportController.php:48:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/StoreInviteController.php:40:    private function authorizeInvite(Request $request, Store $store): void
app/Http/Requests/Api/Admin/V1/UpdateProductRequest.php:13:class UpdateProductRequest extends FormRequest
app/Http/Requests/Api/Admin/V1/UpdateProductRequest.php:15:    public function authorize(): bool
app/Http/Controllers/Api/Admin/V1/ShippingRateController.php:52:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/AnalyticsSummaryController.php:64:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/SearchIndexController.php:66:    private function authorizeStore(Request $request, Store $store): void
app/Http/Controllers/Api/Admin/V1/CollectionController.php:103:    private function authorizeStore(Request $request, Store $store): void


cmd: sed -n '1,260p' app/Http/Requests/Api/Admin/V1/StoreProductRequest.php


cmd: sed -n '1,300p' app/Http/Requests/Api/Admin/V1/UpdateProductRequest.php


cmd: sed -n '1,180p' app/Http/Requests/Api/Admin/V1/CreateProductMediaUploadRequest.php


cmd: sed -n '1,220p' app/Http/Requests/Api/Admin/V1/CreateOrderRefundRequest.php


cmd: sed -n '1,220p' app/Http/Requests/Api/Admin/V1/CreateOrderFulfillmentRequest.php


server: laravel-boost

tool: database-schema

type: text

engine: sqlite

store_id: integer

date: varchar

orders_count: integer

revenue_amount: integer

aov_amount: integer

visits_count: integer

add_to_cart_count: integer

checkout_started_count: integer

checkout_completed_count: integer

type: varchar

session_id: varchar

customer_id: integer

properties_json: text

client_event_id: varchar

occurred_at: datetime

created_at: datetime

app_id: integer

scopes_json: text

status: varchar

installed_at: datetime

key: varchar

value: text

expiration: integer

owner: varchar

cart_id: integer

variant_id: integer

quantity: integer

unit_price_amount: integer

line_subtotal_amount: integer

line_discount_amount: integer

line_total_amount: integer

currency: varchar

cart_version: integer

updated_at: datetime

payment_method: varchar

email: varchar

shipping_address_json: text

billing_address_json: text

shipping_method_id: integer

discount_code: varchar

tax_provider_snapshot_json: text

totals_json: text

expires_at: datetime

collection_id: integer

product_id: integer

position: integer

title: varchar

handle: varchar

description_html: text

label: varchar

address_json: text

token: varchar

varchar

password_hash: varchar

format: varchar

filters_json: text

row_count: integer

storage_key: varchar

error_message: text

download_expires_at: datetime

completed_at: datetime

failed_at: datetime

title: varchar

title: varchar

title: varchar

query: text


command: sed -n '1,300p' app/Http/Requests/Api/Admin/V1/UpdateProductRequest.php

UpdateProductRequest.php

type: read

aggregated_output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use App\Models\Product;
use App\Models\ProductVariant;
use App\Models\Store;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class UpdateProductRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $store = $this->routeStore();
        $product = $this->routeProduct();

        return [
            'title' => ['sometimes', 'string', 'max:255'],
            'handle' => [
                'sometimes',
                'nullable',
                'string',
                'max:255',
                'regex:/^[a-z0-9]+(?:-[a-z0-9]+)*$/',
                Rule::unique('products', 'handle')
                    ->where('store_id', $store->getKey())
                    ->ignore($product?->getKey()),
            ],
            'description_html' => ['sometimes', 'nullable', 'string', 'max:65535'],
            'vendor' => ['sometimes', 'nullable', 'string', 'max:255'],
            'product_type' => ['sometimes', 'nullable', 'string', 'max:255'],
            'status' => ['sometimes', Rule::in(['draft', 'active', 'archived'])],
            'tags' => ['sometimes', 'array', 'max:50'],
            'tags.*' => ['string', 'max:255'],
            'options' => ['sometimes', 'array', 'max:3'],
            'options.*.name' => ['required_with:options', 'string', 'max:255'],
            'options.*.position' => ['required_with:options', 'integer', 'min:1', 'max:3'],
            'options.*.values' => ['sometimes', 'array', 'max:100'],
            'options.*.values.*' => ['string', 'max:255'],
            'variants' => ['sometimes', 'array', 'min:1', 'max:100'],
            'variants.*.id' => ['sometimes', 'integer'],
            'variants.*.sku' => ['required_with:variants', 'string', 'max:255'],
            'variants.*.barcode' => ['sometimes', 'nullable', 'string', 'max:255'],
            'variants.*.price_amount' => ['required_with:variants', 'integer', 'min:0'],
            'variants.*.compare_at_amount' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.currency' => ['sometimes', 'string', 'size:3'],
            'variants.*.weight_g' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.requires_shipping' => ['sometimes', 'boolean'],
            'variants.*.is_default' => ['required_with:variants', 'boolean'],
            'variants.*.position' => ['sometimes', 'integer', 'min:0'],
            'variants.*.status' => ['sometimes', Rule::in(['active', 'archived'])],
            'variants.*.option_values' => ['sometimes', 'array'],
            'variants.*.option_values.*.option_name' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.option_values.*.value' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.inventory' => ['sometimes', 'array'],
            'variants.*.inventory.quantity_on_hand' => ['sometimes', 'integer', 'min:0'],
            'variants.*.inventory.policy' => ['sometimes', Rule::in(['deny', 'continue'])],
            'collections' => ['sometimes', 'array'],
            'collections.*' => ['integer', Rule::exists('collections', 'id')->where('store_id', $store->getKey())],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateVariantDefaults($validator);
                $this->validateVariantPrices($validator);
                $this->validateVariantSkus($validator);
                $this->validateVariantIds($validator);
            },
        ];
    }

    private function routeStore(): Store
    {
        $store = $this->route('store');

        return $store instanceof Store ? $store : Store::query()->findOrFail($store);
    }

    private function routeProduct(): ?Product
    {
        $product = $this->route('product');

        return $product instanceof Product ? $product : null;
    }

    private function validateVariantDefaults(Validator $validator): void
    {
        if (! $this->has('variants')) {
            return;
        }

        $variants = $this->input('variants', []);

        if (! is_array($variants)) {
            return;
        }

        $defaultCount = collect($variants)
            ->filter(fn (mixed $variant): bool => is_array($variant) && (bool) ($variant['is_default'] ?? false))
            ->count();

        if ($defaultCount !== 1) {
            $validator->errors()->add('variants', __('Exactly one product variant must be marked as default.'));
        }
    }

    private function validateVariantPrices(Validator $validator): void
    {
        foreach ($this->input('variants', []) as $index => $variant) {
            if (! is_array($variant) || ! isset($variant['compare_at_amount'])) {
                continue;
            }

            $compareAtAmount = $variant['compare_at_amount'];

            if ($compareAtAmount === null || $compareAtAmount === '') {
                continue;
            }

            if ((int) $compareAtAmount <= (int) ($variant['price_amount'] ?? 0)) {
                $validator->errors()->add("variants.{$index}.compare_at_amount", __('The compare at amount must be greater than the price amount.'));
            }
        }
    }

    private function validateVariantSkus(Validator $validator): void
    {
        if (! $this->has('variants')) {
            return;
        }

        $skus = collect($this->input('variants', []))
            ->map(fn (mixed $variant): string => is_array($variant) ? trim((string) ($variant['sku'] ?? '')) : '')
            ->filter()
            ->values();

        if ($skus->duplicates()->isNotEmpty()) {
            $validator->errors()->add('variants.0.sku', __('Each variant SKU must be unique for this store.'));

            return;
        }

        $product = $this->routeProduct();

        $conflictingSku = ProductVariant::withoutGlobalScopes()
            ->whereIn('sku', $skus->all())
            ->whereHas('product', function (Builder $query): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $this->routeStore()->getKey());
            })
            ->when($product instanceof Product, function (Builder $query) use ($product): void {
                $query->where('product_id', '!=', $product->getKey());
            })
            ->value('sku');

        if ($conflictingSku !== null) {
            $validator->errors()->add('variants.0.sku', __('The SKU [:sku] is already used in this store.', ['sku' => $conflictingSku]));
        }
    }

    private function validateVariantIds(Validator $validator): void
    {
        $product = $this->routeProduct();

        if (! $product instanceof Product) {
            return;
        }

        $variantIds = collect($this->input('variants', []))
            ->pluck('id')
            ->filter()
            ->map(fn (mixed $variantId): int => (int) $variantId)
            ->values();

        if ($variantIds->isEmpty()) {
            return;
        }

        $validCount = ProductVariant::withoutGlobalScopes()
            ->where('product_id', $product->getKey())
            ->whereIn('id', $variantIds->all())
            ->count();

        if ($validCount !== $variantIds->count()) {
            $validator->errors()->add('variants', __('Variant IDs must belong to the product being updated.'));
        }
    }
}

status: completed


command: sed -n '1,220p' app/Http/Requests/Api/Admin/V1/CreateOrderRefundRequest.php

aggregated_output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;

class CreateOrderRefundRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'amount' => ['nullable', 'integer', 'min:1'],
            'reason' => ['nullable', 'string', 'max:500'],
            'restock' => ['sometimes', 'boolean'],
            'line_items' => ['nullable', 'array'],
            'line_items.*.order_line_id' => ['required_with:line_items', 'integer'],
            'line_items.*.quantity' => ['required_with:line_items', 'integer', 'min:1'],
        ];
    }

    /**
     * @return array<int, int>
     */
    public function lineQuantities(): array
    {
        return collect($this->validated('line_items', []))
            ->mapWithKeys(fn (array $line): array => [(int) $line['order_line_id'] => (int) $line['quantity']])
            ->all();
    }
}


command: sed -n '1,180p' app/Http/Requests/Api/Admin/V1/CreateProductMediaUploadRequest.php

aggregated_output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class CreateProductMediaUploadRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'filename' => ['required', 'string', 'max:255'],
            'content_type' => ['required', Rule::in(['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'video/mp4'])],
            'byte_size' => ['required', 'integer', 'min:1'],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateExtension($validator);
                $this->validateByteSize($validator);
            },
        ];
    }

    private function validateExtension(Validator $validator): void
    {
        $extension = strtolower(pathinfo((string) $this->input('filename'), PATHINFO_EXTENSION));
        $allowedExtensions = match ((string) $this->input('content_type')) {
            'image/jpeg' => ['jpg', 'jpeg'],
            'image/png' => ['png'],
            'image/webp' => ['webp'],
            'image/avif' => ['avif'],
            'video/mp4' => ['mp4'],
            default => [],
        };

        if ($extension === '' || ! in_array($extension, $allowedExtensions, true)) {
            $validator->errors()->add('filename', __('The filename extension must match the content type.'));
        }
    }

    private function validateByteSize(Validator $validator): void
    {
        $limit = $this->input('content_type') === 'video/mp4'
            ? 500 * 1024 * 1024
            : 50 * 1024 * 1024;

        if ((int) $this->input('byte_size') > $limit) {
            $validator->errors()->add('byte_size', __('The uploaded media file is too large.'));
        }
    }
}


command: sed -n '1,260p' app/Http/Requests/Api/Admin/V1/StoreProductRequest.php

aggregated_output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use App\Models\ProductVariant;
use App\Models\Store;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class StoreProductRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $store = $this->routeStore();

        return [
            'title' => ['required', 'string', 'max:255'],
            'handle' => [
                'sometimes',
                'nullable',
                'string',
                'max:255',
                'regex:/^[a-z0-9]+(?:-[a-z0-9]+)*$/',
                Rule::unique('products', 'handle')->where('store_id', $store->getKey()),
            ],
            'description_html' => ['sometimes', 'nullable', 'string', 'max:65535'],
            'vendor' => ['sometimes', 'nullable', 'string', 'max:255'],
            'product_type' => ['sometimes', 'nullable', 'string', 'max:255'],
            'status' => ['sometimes', Rule::in(['draft', 'active'])],
            'tags' => ['sometimes', 'array', 'max:50'],
            'tags.*' => ['string', 'max:255'],
            'options' => ['sometimes', 'array', 'max:3'],
            'options.*.name' => ['required_with:options', 'string', 'max:255'],
            'options.*.position' => ['required_with:options', 'integer', 'min:1', 'max:3'],
            'options.*.values' => ['sometimes', 'array', 'max:100'],
            'options.*.values.*' => ['string', 'max:255'],
            'variants' => ['required', 'array', 'min:1', 'max:100'],
            'variants.*.sku' => ['required', 'string', 'max:255'],
            'variants.*.barcode' => ['sometimes', 'nullable', 'string', 'max:255'],
            'variants.*.price_amount' => ['required', 'integer', 'min:0'],
            'variants.*.compare_at_amount' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.currency' => ['sometimes', 'string', 'size:3'],
            'variants.*.weight_g' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.requires_shipping' => ['sometimes', 'boolean'],
            'variants.*.is_default' => ['required', 'boolean'],
            'variants.*.position' => ['sometimes', 'integer', 'min:0'],
            'variants.*.status' => ['sometimes', Rule::in(['active', 'archived'])],
            'variants.*.option_values' => ['sometimes', 'array'],
            'variants.*.option_values.*.option_name' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.option_values.*.value' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.inventory' => ['sometimes', 'array'],
            'variants.*.inventory.quantity_on_hand' => ['sometimes', 'integer', 'min:0'],
            'variants.*.inventory.policy' => ['sometimes', Rule::in(['deny', 'continue'])],
            'collections' => ['sometimes', 'array'],
            'collections.*' => ['integer', Rule::exists('collections', 'id')->where('store_id', $store->getKey())],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateVariantDefaults($validator);
                $this->validateVariantPrices($validator);
                $this->validateVariantSkus($validator);
            },
        ];
    }

    private function routeStore(): Store
    {
        $store = $this->route('store');

        return $store instanceof Store ? $store : Store::query()->findOrFail($store);
    }

    private function validateVariantDefaults(Validator $validator): void
    {
        $variants = $this->input('variants', []);

        if (! is_array($variants)) {
            return;
        }

        $defaultCount = collect($variants)
            ->filter(fn (mixed $variant): bool => is_array($variant) && (bool) ($variant['is_default'] ?? false))
            ->count();

        if ($defaultCount !== 1) {
            $validator->errors()->add('variants', __('Exactly one product variant must be marked as default.'));
        }
    }

    private function validateVariantPrices(Validator $validator): void
    {
        foreach ($this->input('variants', []) as $index => $variant) {
            if (! is_array($variant) || ! isset($variant['compare_at_amount'])) {
                continue;
            }

            $compareAtAmount = $variant['compare_at_amount'];

            if ($compareAtAmount === null || $compareAtAmount === '') {
                continue;
            }

            if ((int) $compareAtAmount <= (int) ($variant['price_amount'] ?? 0)) {
                $validator->errors()->add("variants.{$index}.compare_at_amount", __('The compare at amount must be greater than the price amount.'));
            }
        }
    }

    private function validateVariantSkus(Validator $validator): void
    {
        $skus = collect($this->input('variants', []))
            ->map(fn (mixed $variant): string => is_array($variant) ? trim((string) ($variant['sku'] ?? '')) : '')
            ->filter()
            ->values();

        if ($skus->duplicates()->isNotEmpty()) {
            $validator->errors()->add('variants.0.sku', __('Each variant SKU must be unique for this store.'));

            return;
        }

        $conflictingSku = ProductVariant::withoutGlobalScopes()
            ->whereIn('sku', $skus->all())
            ->whereHas('product', function (Builder $query): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $this->routeStore()->getKey());
            })
            ->value('sku');

        if ($conflictingSku !== null) {
            $validator->errors()->add('variants.0.sku', __('The SKU [:sku] is already used in this store.', ['sku' => $conflictingSku]));
        }
    }
}


command: sed -n '1,220p' app/Http/Requests/Api/Admin/V1/CreateOrderFulfillmentRequest.php

aggregated_output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;

class CreateOrderFulfillmentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'line_items' => ['required', 'array', 'min:1'],
            'line_items.*.order_line_id' => ['required', 'integer'],
            'line_items.*.quantity' => ['required', 'integer', 'min:1'],
            'tracking_company' => ['nullable', 'string', 'max:255'],
            'tracking_number' => ['nullable', 'string', 'max:255'],
            'tracking_url' => ['nullable', 'url', 'max:2048'],
        ];
    }

    /**
     * @return array<int, int>
     */
    public function lineQuantities(): array
    {
        return collect($this->validated('line_items'))
            ->mapWithKeys(fn (array $line): array => [(int) $line['order_line_id'] => (int) $line['quantity']])
            ->all();
    }
}


output:
Chunk ID: a2a8f0
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1530
Output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use App\Models\ProductVariant;
use App\Models\Store;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class StoreProductRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $store = $this->routeStore();

        return [
            'title' => ['required', 'string', 'max:255'],
            'handle' => [
                'sometimes',
                'nullable',
                'string',
                'max:255',
                'regex:/^[a-z0-9]+(?:-[a-z0-9]+)*$/',
                Rule::unique('products', 'handle')->where('store_id', $store->getKey()),
            ],
            'description_html' => ['sometimes', 'nullable', 'string', 'max:65535'],
            'vendor' => ['sometimes', 'nullable', 'string', 'max:255'],
            'product_type' => ['sometimes', 'nullable', 'string', 'max:255'],
            'status' => ['sometimes', Rule::in(['draft', 'active'])],
            'tags' => ['sometimes', 'array', 'max:50'],
            'tags.*' => ['string', 'max:255'],
            'options' => ['sometimes', 'array', 'max:3'],
            'options.*.name' => ['required_with:options', 'string', 'max:255'],
            'options.*.position' => ['required_with:options', 'integer', 'min:1', 'max:3'],
            'options.*.values' => ['sometimes', 'array', 'max:100'],
            'options.*.values.*' => ['string', 'max:255'],
            'variants' => ['required', 'array', 'min:1', 'max:100'],
            'variants.*.sku' => ['required', 'string', 'max:255'],
            'variants.*.barcode' => ['sometimes', 'nullable', 'string', 'max:255'],
            'variants.*.price_amount' => ['required', 'integer', 'min:0'],
            'variants.*.compare_at_amount' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.currency' => ['sometimes', 'string', 'size:3'],
            'variants.*.weight_g' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.requires_shipping' => ['sometimes', 'boolean'],
            'variants.*.is_default' => ['required', 'boolean'],
            'variants.*.position' => ['sometimes', 'integer', 'min:0'],
            'variants.*.status' => ['sometimes', Rule::in(['active', 'archived'])],
            'variants.*.option_values' => ['sometimes', 'array'],
            'variants.*.option_values.*.option_name' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.option_values.*.value' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.inventory' => ['sometimes', 'array'],
            'variants.*.inventory.quantity_on_hand' => ['sometimes', 'integer', 'min:0'],
            'variants.*.inventory.policy' => ['sometimes', Rule::in(['deny', 'continue'])],
            'collections' => ['sometimes', 'array'],
            'collections.*' => ['integer', Rule::exists('collections', 'id')->where('store_id', $store->getKey())],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateVariantDefaults($validator);
                $this->validateVariantPrices($validator);
                $this->validateVariantSkus($validator);
            },
        ];
    }

    private function routeStore(): Store
    {
        $store = $this->route('store');

        return $store instanceof Store ? $store : Store::query()->findOrFail($store);
    }

    private function validateVariantDefaults(Validator $validator): void
    {
        $variants = $this->input('variants', []);

        if (! is_array($variants)) {
            return;
        }

        $defaultCount = collect($variants)
            ->filter(fn (mixed $variant): bool => is_array($variant) && (bool) ($variant['is_default'] ?? false))
            ->count();

        if ($defaultCount !== 1) {
            $validator->errors()->add('variants', __('Exactly one product variant must be marked as default.'));
        }
    }

    private function validateVariantPrices(Validator $validator): void
    {
        foreach ($this->input('variants', []) as $index => $variant) {
            if (! is_array($variant) || ! isset($variant['compare_at_amount'])) {
                continue;
            }

            $compareAtAmount = $variant['compare_at_amount'];

            if ($compareAtAmount === null || $compareAtAmount === '') {
                continue;
            }

            if ((int) $compareAtAmount <= (int) ($variant['price_amount'] ?? 0)) {
                $validator->errors()->add("variants.{$index}.compare_at_amount", __('The compare at amount must be greater than the price amount.'));
            }
        }
    }

    private function validateVariantSkus(Validator $validator): void
    {
        $skus = collect($this->input('variants', []))
            ->map(fn (mixed $variant): string => is_array($variant) ? trim((string) ($variant['sku'] ?? '')) : '')
            ->filter()
            ->values();

        if ($skus->duplicates()->isNotEmpty()) {
            $validator->errors()->add('variants.0.sku', __('Each variant SKU must be unique for this store.'));

            return;
        }

        $conflictingSku = ProductVariant::withoutGlobalScopes()
            ->whereIn('sku', $skus->all())
            ->whereHas('product', function (Builder $query): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $this->routeStore()->getKey());
            })
            ->value('sku');

        if ($conflictingSku !== null) {
            $validator->errors()->add('variants.0.sku', __('The SKU [:sku] is already used in this store.', ['sku' => $conflictingSku]));
        }
    }
}


output:
Chunk ID: b94356
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 1948
Output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use App\Models\Product;
use App\Models\ProductVariant;
use App\Models\Store;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class UpdateProductRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        $store = $this->routeStore();
        $product = $this->routeProduct();

        return [
            'title' => ['sometimes', 'string', 'max:255'],
            'handle' => [
                'sometimes',
                'nullable',
                'string',
                'max:255',
                'regex:/^[a-z0-9]+(?:-[a-z0-9]+)*$/',
                Rule::unique('products', 'handle')
                    ->where('store_id', $store->getKey())
                    ->ignore($product?->getKey()),
            ],
            'description_html' => ['sometimes', 'nullable', 'string', 'max:65535'],
            'vendor' => ['sometimes', 'nullable', 'string', 'max:255'],
            'product_type' => ['sometimes', 'nullable', 'string', 'max:255'],
            'status' => ['sometimes', Rule::in(['draft', 'active', 'archived'])],
            'tags' => ['sometimes', 'array', 'max:50'],
            'tags.*' => ['string', 'max:255'],
            'options' => ['sometimes', 'array', 'max:3'],
            'options.*.name' => ['required_with:options', 'string', 'max:255'],
            'options.*.position' => ['required_with:options', 'integer', 'min:1', 'max:3'],
            'options.*.values' => ['sometimes', 'array', 'max:100'],
            'options.*.values.*' => ['string', 'max:255'],
            'variants' => ['sometimes', 'array', 'min:1', 'max:100'],
            'variants.*.id' => ['sometimes', 'integer'],
            'variants.*.sku' => ['required_with:variants', 'string', 'max:255'],
            'variants.*.barcode' => ['sometimes', 'nullable', 'string', 'max:255'],
            'variants.*.price_amount' => ['required_with:variants', 'integer', 'min:0'],
            'variants.*.compare_at_amount' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.currency' => ['sometimes', 'string', 'size:3'],
            'variants.*.weight_g' => ['sometimes', 'nullable', 'integer', 'min:0'],
            'variants.*.requires_shipping' => ['sometimes', 'boolean'],
            'variants.*.is_default' => ['required_with:variants', 'boolean'],
            'variants.*.position' => ['sometimes', 'integer', 'min:0'],
            'variants.*.status' => ['sometimes', Rule::in(['active', 'archived'])],
            'variants.*.option_values' => ['sometimes', 'array'],
            'variants.*.option_values.*.option_name' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.option_values.*.value' => ['required_with:variants.*.option_values', 'string', 'max:255'],
            'variants.*.inventory' => ['sometimes', 'array'],
            'variants.*.inventory.quantity_on_hand' => ['sometimes', 'integer', 'min:0'],
            'variants.*.inventory.policy' => ['sometimes', Rule::in(['deny', 'continue'])],
            'collections' => ['sometimes', 'array'],
            'collections.*' => ['integer', Rule::exists('collections', 'id')->where('store_id', $store->getKey())],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateVariantDefaults($validator);
                $this->validateVariantPrices($validator);
                $this->validateVariantSkus($validator);
                $this->validateVariantIds($validator);
            },
        ];
    }

    private function routeStore(): Store
    {
        $store = $this->route('store');

        return $store instanceof Store ? $store : Store::query()->findOrFail($store);
    }

    private function routeProduct(): ?Product
    {
        $product = $this->route('product');

        return $product instanceof Product ? $product : null;
    }

    private function validateVariantDefaults(Validator $validator): void
    {
        if (! $this->has('variants')) {
            return;
        }

        $variants = $this->input('variants', []);

        if (! is_array($variants)) {
            return;
        }

        $defaultCount = collect($variants)
            ->filter(fn (mixed $variant): bool => is_array($variant) && (bool) ($variant['is_default'] ?? false))
            ->count();

        if ($defaultCount !== 1) {
            $validator->errors()->add('variants', __('Exactly one product variant must be marked as default.'));
        }
    }

    private function validateVariantPrices(Validator $validator): void
    {
        foreach ($this->input('variants', []) as $index => $variant) {
            if (! is_array($variant) || ! isset($variant['compare_at_amount'])) {
                continue;
            }

            $compareAtAmount = $variant['compare_at_amount'];

            if ($compareAtAmount === null || $compareAtAmount === '') {
                continue;
            }

            if ((int) $compareAtAmount <= (int) ($variant['price_amount'] ?? 0)) {
                $validator->errors()->add("variants.{$index}.compare_at_amount", __('The compare at amount must be greater than the price amount.'));
            }
        }
    }

    private function validateVariantSkus(Validator $validator): void
    {
        if (! $this->has('variants')) {
            return;
        }

        $skus = collect($this->input('variants', []))
            ->map(fn (mixed $variant): string => is_array($variant) ? trim((string) ($variant['sku'] ?? '')) : '')
            ->filter()
            ->values();

        if ($skus->duplicates()->isNotEmpty()) {
            $validator->errors()->add('variants.0.sku', __('Each variant SKU must be unique for this store.'));

            return;
        }

        $product = $this->routeProduct();

        $conflictingSku = ProductVariant::withoutGlobalScopes()
            ->whereIn('sku', $skus->all())
            ->whereHas('product', function (Builder $query): void {
                $query
                    ->withoutGlobalScopes()
                    ->where('store_id', $this->routeStore()->getKey());
            })
            ->when($product instanceof Product, function (Builder $query) use ($product): void {
                $query->where('product_id', '!=', $product->getKey());
            })
            ->value('sku');

        if ($conflictingSku !== null) {
            $validator->errors()->add('variants.0.sku', __('The SKU [:sku] is already used in this store.', ['sku' => $conflictingSku]));
        }
    }

    private function validateVariantIds(Validator $validator): void
    {
        $product = $this->routeProduct();

        if (! $product instanceof Product) {
            return;
        }

        $variantIds = collect($this->input('variants', []))
            ->pluck('id')
            ->filter()
            ->map(fn (mixed $variantId): int => (int) $variantId)
            ->values();

        if ($variantIds->isEmpty()) {
            return;
        }

        $validCount = ProductVariant::withoutGlobalScopes()
            ->where('product_id', $product->getKey())
            ->whereIn('id', $variantIds->all())
            ->count();

        if ($validCount !== $variantIds->count()) {
            $validator->errors()->add('variants', __('Variant IDs must belong to the product being updated.'));
        }
    }
}


output:
Chunk ID: 578a47
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 524
Output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;

class CreateProductMediaUploadRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'filename' => ['required', 'string', 'max:255'],
            'content_type' => ['required', Rule::in(['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'video/mp4'])],
            'byte_size' => ['required', 'integer', 'min:1'],
        ];
    }

    /**
     * @return array<int, callable>
     */
    public function after(): array
    {
        return [
            function (Validator $validator): void {
                $this->validateExtension($validator);
                $this->validateByteSize($validator);
            },
        ];
    }

    private function validateExtension(Validator $validator): void
    {
        $extension = strtolower(pathinfo((string) $this->input('filename'), PATHINFO_EXTENSION));
        $allowedExtensions = match ((string) $this->input('content_type')) {
            'image/jpeg' => ['jpg', 'jpeg'],
            'image/png' => ['png'],
            'image/webp' => ['webp'],
            'image/avif' => ['avif'],
            'video/mp4' => ['mp4'],
            default => [],
        };

        if ($extension === '' || ! in_array($extension, $allowedExtensions, true)) {
            $validator->errors()->add('filename', __('The filename extension must match the content type.'));
        }
    }

    private function validateByteSize(Validator $validator): void
    {
        $limit = $this->input('content_type') === 'video/mp4'
            ? 500 * 1024 * 1024
            : 50 * 1024 * 1024;

        if ((int) $this->input('byte_size') > $limit) {
            $validator->errors()->add('byte_size', __('The uploaded media file is too large.'));
        }
    }
}


output:
Chunk ID: 9a952f
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 275
Output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;

class CreateOrderRefundRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'amount' => ['nullable', 'integer', 'min:1'],
            'reason' => ['nullable', 'string', 'max:500'],
            'restock' => ['sometimes', 'boolean'],
            'line_items' => ['nullable', 'array'],
            'line_items.*.order_line_id' => ['required_with:line_items', 'integer'],
            'line_items.*.quantity' => ['required_with:line_items', 'integer', 'min:1'],
        ];
    }

    /**
     * @return array<int, int>
     */
    public function lineQuantities(): array
    {
        return collect($this->validated('line_items', []))
            ->mapWithKeys(fn (array $line): array => [(int) $line['order_line_id'] => (int) $line['quantity']])
            ->all();
    }
}


output:
Chunk ID: 16300c
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 278
Output:
<?php

namespace App\Http\Requests\Api\Admin\V1;

use Illuminate\Foundation\Http\FormRequest;

class CreateOrderFulfillmentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    /**
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'line_items' => ['required', 'array', 'min:1'],
            'line_items.*.order_line_id' => ['required', 'integer'],
            'line_items.*.quantity' => ['required', 'integer', 'min:1'],
            'tracking_company' => ['nullable', 'string', 'max:255'],
            'tracking_number' => ['nullable', 'string', 'max:255'],
            'tracking_url' => ['nullable', 'url', 'max:2048'],
        ];
    }

    /**
     * @return array<int, int>
     */
    public function lineQuantities(): array
    {
        return collect($this->validated('line_items'))
            ->mapWithKeys(fn (array $line): array => [(int) $line['order_line_id'] => (int) $line['quantity']])
            ->all();
    }
}


cmd: sed -n '1,300p' app/Http/Controllers/Api/Admin/V1/ProductController.php


cmd: sed -n '1,180p' app/Http/Controllers/Api/Admin/V1/OrderRefundController.php


cmd: sed -n '1,160p' app/Http/Controllers/Api/Admin/V1/OrderFulfillmentController.php


cmd: sed -n '1,160p' app/Http/Controllers/Api/Admin/V1/CollectionController.php


cmd: sed -n '1,220p' app/Livewire/Admin/Pages/Form.php


cmd: sed -n '1,240p' app/Actions/SanitizeHtml.php


command: sed -n '1,300p' app/Http/Controllers/Api/Admin/V1/ProductController.php

aggregated_output:
<?php

namespace App\Http\Controllers\Api\Admin\V1;

use App\Actions\SanitizeHtml;
use App\Enums\MediaStatus;
use App\Enums\MediaType;
use App\Enums\ProductStatus;
use App\Enums\VariantStatus;
use App\Exceptions\InvalidProductTransitionException;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\Admin\V1\CreateProductMediaUploadRequest;
use App\Http\Requests\Api\Admin\V1\StoreProductRequest;
use App\Http\Requests\Api\Admin\V1\UpdateProductRequest;
use App\Http\Resources\Admin\V1\ProductResource;
use App\Models\InventoryItem;
use App\Models\Product;
use App\Models\ProductMedia;
use App\Models\ProductOption;
use App\Models\ProductOptionValue;
use App\Models\ProductVariant;
use App\Models\Store;
use App\Services\ProductService;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
use InvalidArgumentException;
use RuntimeException;
use Throwable;

class ProductController extends Controller
{
    public function index(Request $request, Store $store): AnonymousResourceCollection
    {
        $this->authorizeStore($request, $store);

        $validated = $request->validate([
            'status' => ['nullable', Rule::in(['draft', 'active', 'archived'])],
            'query' => ['nullable', 'string', 'max:255'],
            'collection_id' => ['nullable', 'integer'],
            'sort' => ['nullable', Rule::in(['title_asc', 'title_desc', 'created_at_asc', 'created_at_desc', 'updated_at_desc'])],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
        ]);

        $query = Product::withoutGlobalScopes()
            ->with([
                'media',
                'variants.inventoryItem',
            ])
            ->withCount('variants')
            ->where('store_id', $store->getKey())
            ->when(data_get($validated, 'status'), fn (Builder $query, string $status) => $query->where('status', $status))
            ->when(data_get($validated, 'collection_id'), function (Builder $query, int $collectionId): void {
                $query->whereHas('collections', fn (Builder $query) => $query->withoutGlobalScopes()->whereKey($collectionId));
            })
            ->when(data_get($validated, 'query'), function (Builder $query, string $search): void {
                $like = '%'.$search.'%';

                $query->where(function (Builder $query) use ($like): void {
                    $query
                        ->where('title', 'like', $like)
                        ->orWhere('vendor', 'like', $like)
                        ->orWhereHas('variants', fn (Builder $query) => $query->withoutGlobalScopes()->where('sku', 'like', $like));
                });
            });

        $this->applySort($query, (string) data_get($validated, 'sort', 'updated_at_desc'));

        return ProductResource::collection($query->paginate((int) data_get($validated, 'per_page', 25)));
    }

    public function show(Request $request, Store $store, Product $product): ProductResource
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessProductBelongsToStore($product, $store);

        return ProductResource::make($this->loadProduct($product));
    }

    public function store(StoreProductRequest $request, Store $store, ProductService $products): JsonResponse
    {
        $this->authorizeStore($request, $store);

        $validated = $request->validated();

        try {
            $product = DB::transaction(function () use ($products, $store, $validated): Product {
                $product = $products->create($store, $this->attributesForCreate($validated, $store));

                if (array_key_exists('collections', $validated)) {
                    $product->collections()->sync($this->integerList($validated['collections']));
                }

                return $product->refresh();
            });
        } catch (InvalidProductTransitionException|InvalidArgumentException|RuntimeException $exception) {
            $this->throwProductValidationException($exception);
        }

        return ProductResource::make($this->loadProduct($product))
            ->response()
            ->setStatusCode(201);
    }

    public function update(UpdateProductRequest $request, Store $store, Product $product, ProductService $products): ProductResource
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessProductBelongsToStore($product, $store);

        $validated = $request->validated();

        try {
            $product = DB::transaction(function () use ($products, $store, $product, $validated): Product {
                $product = Produ…1783 chars truncated…ducts): JsonResponse
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessProductBelongsToStore($product, $store);

        $products->transitionStatus($product, ProductStatus::Archived);

        return response()->json([
            'data' => [
                'id' => $product->getKey(),
                'status' => ProductStatus::Archived->value,
                'updated_at' => $product->refresh()->updated_at?->toIso8601String(),
            ],
        ]);
    }

    public function presignUpload(CreateProductMediaUploadRequest $request, Store $store, Product $product): JsonResponse
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessProductBelongsToStore($product, $store);

        $validated = $request->validated();
        $expiresAt = now()->addMinutes(10);
        $storageKey = sprintf(
            'media/originals/%d/%s.%s',
            $product->getKey(),
            Str::uuid(),
            $this->extensionForContentType((string) $validated['content_type']),
        );
        $media = ProductMedia::withoutGlobalScopes()->create([
            'product_id' => $product->getKey(),
            'type' => $this->mediaTypeForContentType((string) $validated['content_type']),
            'storage_key' => $storageKey,
            'alt_text' => $product->title,
            'mime_type' => $validated['content_type'],
            'byte_size' => (int) $validated['byte_size'],
            'position' => $this->nextMediaPosition($product),
            'status' => MediaStatus::Processing,
        ]);
        $upload = $this->temporaryUploadPayload(Storage::disk('public'), $storageKey, $expiresAt);

        return response()->json([
            'upload_url' => $upload['url'],
            'method' => 'PUT',
            'headers' => [
                ...$upload['headers'],
                'Content-Type' => $validated['content_type'],
            ],
            'storage_key' => $storageKey,
            'media_id' => $media->getKey(),
            'expires_at' => $expiresAt->toIso8601String(),
        ], 201);
    }

    private function authorizeStore(Request $request, Store $store): void
    {
        if (! $request->attributes->has('admin_api_oauth_token')) {
            abort_unless($request->user()?->stores()->whereKey($store->getKey())->exists(), 403);
        }

        app()->instance('current_store', $store);
    }

    private function abortUnlessProductBelongsToStore(Product $product, Store $store): void
    {
        abort_unless((int) $product->store_id === $store->getKey(), 404);
    }

    private function loadProduct(Product $product): Product
    {
        return $product->load([
            'collections',
            'media',
            'options.values',
            'variants.inventoryItem',
            'variants.optionValues.option',
        ])->loadCount('variants');
    }

    private function applySort(Builder $query, string $sort): void
    {
        match ($sort) {
            'title_asc' => $query->orderBy('title')->orderBy('id'),
            'title_desc' => $query->orderByDesc('title')->orderByDesc('id'),
            'created_at_asc' => $query->orderBy('created_at')->orderBy('id'),
            'created_at_desc' => $query->orderByDesc('created_at')->orderByDesc('id'),
            default => $query->orderByDesc('updated_at')->orderByDesc('id'),
        };
    }

    /**
     * @param  array<string, mixed>  $validated
     * @return array<string, mixed>
     */
    private function attributesForCreate(array $validated, Store $store): array
    {
        $attributes = [
            'title' => $validated['title'],
            'description_html' => $this->sanitizeHtml($validated['description_html'] ?? null),
            'vendor' => $validated['vendor'] ?? null,
            'product_type' => $validated['product_type'] ?? null,
            'status' => $validated['status'] ?? ProductStatus::Draft->value,
            'tags' => $this->tagList($validated['tags'] ?? []),
            'options' => $this->optionPayload($validated),
            'variants' => $this->variantPayloads($validated['variants'], $store, true),
        ];

        if (filled($validated['handle'] ?? null)) {
            $attributes['handle'] = Str::slug((string) $validated['handle']);
        }

        return $attributes;
    }

    /**
     * @param  array<string, mixed>  $validated
     * @return array<string, mixed>
     */
    private function attributesForUpdate(array $validated): array
    {
        $attributes = Arr::only($validated, [
            'title',
            'description_html',
            'vendor',
            'product_type',
            'status',
        ]);

        if (array_key_exists('tags', $validated)) {
            $attributes['tags'] = $this->tagList($validated['tags']);
        }

        if (array_key_exists('description_html', $attributes)) {
            $attributes['description_html'] = $this->sanitizeHtml($attributes['description_html']);
        }


command: sed -n '1,180p' app/Http/Controllers/Api/Admin/V1/OrderRefundController.php

aggregated_output:
<?php

namespace App\Http\Controllers\Api\Admin\V1;

use App\Exceptions\InvalidRefundOperationException;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\Admin\V1\CreateOrderRefundRequest;
use App\Http\Resources\Admin\V1\RefundResource;
use App\Models\Order;
use App\Models\Store;
use App\Services\RefundService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class OrderRefundController extends Controller
{
    public function store(CreateOrderRefundRequest $request, Store $store, Order $order, RefundService $refunds): RefundResource|JsonResponse
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessOrderBelongsToStore($order, $store);

        $payload = [
            'lines' => $request->lineQuantities(),
            'reason' => $request->validated('reason'),
            'restock' => (bool) $request->validated('restock', false),
        ];

        if ($request->validated('amount') !== null) {
            $payload['amount'] = $request->validated('amount');
        }

        try {
            $refund = $refunds->process($order, $payload);

            return RefundResource::make($refund)
                ->response()
                ->setStatusCode(201);
        } catch (InvalidRefundOperationException $exception) {
            return response()->json(['message' => $exception->getMessage()], 409);
        }
    }

    private function authorizeStore(Request $request, Store $store): void
    {
        if (! $request->attributes->has('admin_api_oauth_token')) {
            abort_unless($request->user()?->stores()->whereKey($store->getKey())->exists(), 403);
        }

        app()->instance('current_store', $store);
    }

    private function abortUnlessOrderBelongsToStore(Order $order, Store $store): void
    {
        abort_unless((int) $order->store_id === $store->getKey(), 404);
    }
}


command: sed -n '1,160p' app/Http/Controllers/Api/Admin/V1/OrderFulfillmentController.php

aggregated_output:
<?php

namespace App\Http\Controllers\Api\Admin\V1;

use App\Exceptions\InvalidFulfillmentOperationException;
use App\Http\Controllers\Controller;
use App\Http\Requests\Api\Admin\V1\CreateOrderFulfillmentRequest;
use App\Http\Resources\Admin\V1\FulfillmentResource;
use App\Models\Order;
use App\Models\Store;
use App\Services\FulfillmentService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class OrderFulfillmentController extends Controller
{
    public function store(CreateOrderFulfillmentRequest $request, Store $store, Order $order, FulfillmentService $fulfillments): FulfillmentResource|JsonResponse
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessOrderBelongsToStore($order, $store);

        try {
            $fulfillment = $fulfillments->create($order, $request->lineQuantities(), [
                'tracking_company' => $request->validated('tracking_company'),
                'tracking_number' => $request->validated('tracking_number'),
                'tracking_url' => $request->validated('tracking_url'),
            ]);

            return FulfillmentResource::make($fulfillment->load('lines'))
                ->response()
                ->setStatusCode(201);
        } catch (InvalidFulfillmentOperationException $exception) {
            return response()->json(['message' => $exception->getMessage()], 409);
        }
    }

    private function authorizeStore(Request $request, Store $store): void
    {
        if (! $request->attributes->has('admin_api_oauth_token')) {
            abort_unless($request->user()?->stores()->whereKey($store->getKey())->exists(), 403);
        }

        app()->instance('current_store', $store);
    }

    private function abortUnlessOrderBelongsToStore(Order $order, Store $store): void
    {
        abort_unless((int) $order->store_id === $store->getKey(), 404);
    }
}


command: sed -n '1,160p' app/Http/Controllers/Api/Admin/V1/CollectionController.php

aggregated_output:
<?php

namespace App\Http\Controllers\Api\Admin\V1;

use App\Http\Controllers\Controller;
use App\Http\Resources\Admin\V1\CollectionResource;
use App\Models\Collection;
use App\Models\Store;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Illuminate\Validation\Rule;

class CollectionController extends Controller
{
    public function index(Request $request, Store $store): AnonymousResourceCollection
    {
        $this->authorizeStore($request, $store);

        $validated = $request->validate([
            'status' => ['nullable', Rule::in(['draft', 'active', 'archived'])],
            'query' => ['nullable', 'string', 'max:255'],
            'per_page' => ['nullable', 'integer', 'min:1', 'max:100'],
        ]);

        $collections = Collection::withoutGlobalScopes()
            ->withCount('products')
            ->where('store_id', $store->getKey())
            ->when(data_get($validated, 'status'), fn (Builder $query, string $status) => $query->where('status', $status))
            ->when(data_get($validated, 'query'), function (Builder $query, string $search): void {
                $query->where('title', 'like', '%'.$search.'%');
            })
            ->latest('updated_at')
            ->latest('id')
            ->paginate((int) data_get($validated, 'per_page', 25));

        return CollectionResource::collection($collections);
    }

    public function store(Request $request, Store $store): JsonResponse
    {
        $this->authorizeStore($request, $store);

        $validated = $this->validatePayload($request, $store);

        $collection = DB::transaction(function () use ($store, $validated): Collection {
            $collection = Collection::withoutGlobalScopes()->create([
                'store_id' => $store->getKey(),
                ...$this->attributesForCreate($validated),
            ]);

            if (array_key_exists('product_ids', $validated)) {
                $this->replaceProducts($collection, $validated['product_ids']);
            }

            return $collection;
        });

        return CollectionResource::make($this->loadCollection($collection))
            ->response()
            ->setStatusCode(201);
    }

    public function update(Request $request, Store $store, Collection $collection): CollectionResource
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessCollectionBelongsToStore($collection, $store);

        $validated = $this->validatePayload($request, $store, $collection);

        DB::transaction(function () use ($collection, $validated): void {
            $attributes = $this->attributesForUpdate($validated);

            if ($attributes !== []) {
                $collection->update($attributes);
            }

            if (array_key_exists('product_ids', $validated)) {
                $this->replaceProducts($collection, $validated['product_ids']);
            } else {
                $this->addProducts($collection, $validated['add_product_ids'] ?? []);
                $this->removeProducts($collection, $validated['remove_product_ids'] ?? []);
            }
        });

        return CollectionResource::make($this->loadCollection($collection->refresh()));
    }

    public function destroy(Request $request, Store $store, Collection $collection): JsonResponse
    {
        $this->authorizeStore($request, $store);
        $this->abortUnlessCollectionBelongsToStore($collection, $store);

        $collection->delete();

        return response()->json(['message' => 'Collection deleted']);
    }

    private function authorizeStore(Request $request, Store $store): void
    {
        if (! $request->attributes->has('admin_api_oauth_token')) {
            abort_unless($request->user()?->stores()->whereKey($store->getKey())->exists(), 403);
        }

        app()->instance('current_store', $store);
    }

    private function abortUnlessCollectionBelongsToStore(Collection $collection, Store $store): void
    {
        abort_unless((int) $collection->store_id === $store->getKey(), 404);
    }

    /**
     * @return array<string, mixed>
     */
    private function validatePayload(Request $request, Store $store, ?Collection $collection = null): array
    {
        $creating = $collection === null;

        return $request->validate([
            'title' => [$creating ? 'required' : 'sometimes', 'string', 'max:255'],
            'handle' => [
                'sometimes',
                'nullable',
                'string',
                'max:255',
                Rule::unique('collections', 'handle')
                    ->where('store_id', $store->getKey())
                    ->ignore($collection?->getKey()),
            ],
            'description_html' => ['sometimes', 'nullable', 'string', 'max:65535'],
            'type' => [$creating ? 'required' : 'sometimes', Rule::in(['manual', 'automated'])],
            'status' => ['sometimes', Rule::in(['draft', 'active', 'archived'])],
            'product_ids' => ['sometimes', 'array'],
            'product_ids.*' => ['integer', Rule::exists('products', 'id')->where('store_id', $store->getKey())],
            'add_product_ids' => ['sometimes', 'array'],
            'add_product_ids.*' => ['integer', Rule::exists('products', 'id')->where('store_id', $store->getKey())],
            'remove_product_ids' => ['sometimes', 'array'],
            'remove_product_ids.*' => ['integer', Rule::exists('products', 'id')->where('store_id', $store->getKey())],
        ]);
    }

    /**
     * @param  array<string, mixed>  $validated
     * @return array<string, mixed>
     */
    private function attributesForCreate(array $validated): array
    {
        $title = (string) $validated['title'];
        $handle = filled($validated['handle'] ?? null) ? (string) $validated['handle'] : $title;

        return [
            'title' => $title,
            'handle' => Str::slug($handle),
            'description_html' => $validated['description_html'] ?? null,
            'type' => $validated['type'],