output:
Wall time: 4.0855 seconds
Output:
[{"type":"text","text":"# Search Results\n\n## Components Pagination > Large result set\nComponents Pagination | livewire/flux@2.x | Source: https://fluxui.dev/components/pagination#livewire/flux\n\n
Large result set

When working with large result sets, the pagination component automatically adapts to show a reasonable number of page links. It shows the first and last pages, along with a window of pages around the current page, and adds ellipses for any gaps to ensure efficient navigation through numerous pages.

<flux:pagination :paginator=\"$orders\" />

\n\n---\n\n## Testing See also\nTesting | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/testing\n\n## See also\n\n- **[Actions](/docs/4.x/actions)** — Test component actions and interactions\n- **[Forms](/docs/4.x/forms)** — Test form submissions and validation\n- **[Events](/docs/4.x/events)** — Test event dispatching and listening\n- **[Components](/docs/4.x/components)** — Create testable component structure\n\n---\n\n## Components Radio > flux:radio\nComponents Radio | livewire/flux@2.x | Source: https://fluxui.dev/components/radio#livewire/flux\n\n
flux:radio

<ui-table-scroll-area>

Prop

Description

\n    label\n

Label text displayed above the radio button. When provided, wraps the radio button in a flux:field component with an adjacent flux:label component. See the field component.

\n    description\n

Help text displayed below the radio button. When provided alongside label, appears between the label and radio button within the flux:field wrapper. See the field component.

\n    value\n

Value associated with the radio button when used in a group.

\n    checked\n

If true, the radio button is selected by default.

\n    disabled\n

Prevents user interaction with the radio button.

\n    icon\n

Name of the icon to display (for segmented variant).

</ui-table-scroll-area>

<ui-table-scroll-area>

Slot

Description

\n    default\n

Custom content for card variant.

</ui-table-scroll-area>

<ui-table-scroll-area>

Attribute

Description

\n    data-flux-radio\n

Applied to the root element for styling and identification.

\n    data-checked\n

Applied when the radio button is selected.

</ui-table-scroll-area>

\n\n---\n\n## Http Tests Validation Assertions assertInvalid\nHttp Tests | laravel/framework@12.x | Source: https://github.com/laravel/docs/blob/12.x/http-tests.md\n\n\n#### assertInvalid\n\nAssert that the response has validation errors for the given keys. This method may be used for asserting against responses where the validation errors are returned as a JSON structure or where the validation errors have been flashed to the session:\n\n```php\n$response->assertInvalid(['name', 'email']);\n```\n\nYou may also assert that a given key has a particular validation error message. When doing so, you may provide the entire message or only a small portion of the message:\n\n```php\n$response->assertInvalid([\n    'name' => 'The name field is required.',\n    'email' => 'valid email address',\n]);\n```\n\n---\n\n## Components Radio > Buttons\nComponents Radio | livewire/flux@2.x | Source: https://fluxui.dev/components/radio#livewire/flux\n\n
Buttons

Button-style radio options that look like a toolbar. Perfect for action selections and grouped controls where you want a more prominent visual style.

<flux:radio.group variant=\"buttons\" class=\"w-full *:flex-1\" label=\"Feedback type\">    <flux:radio icon=\"bug-ant\" checked>Bug report</flux:radio>    <flux:radio icon=\"light-bulb\">Suggestion</flux:radio>    <flux:radio icon=\"question-mark-circle\">Question</flux:radio></flux:radio.group>

\n\n---\n\n## Attribute Validate\nAttribute Validate | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/attribute-validate\n\nThe `#[Validate]` attribute associates validation rules with component properties, enabling automatic real-time validation and clean rule declaration.\n\n---\n\n## Redirecting Redirecting to full-page components\nRedirecting | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/redirecting\n\n## Redirecting to full-page components\n\nBecause Livewire uses Laravel's built-in redirection feature, you can use all of the redirection methods available to you in a typical Laravel application.\n\nFor example, if you are using a Livewire component as a full-page component for a route like so:\n\n```php\nRoute::livewire('/posts', 'pages::show-posts');\n```\n\nYou can redirect to it simply by using the route path:\n\n```php\npublic function save()\n{\n    // ...\n\n    $this->redirect('/posts');\n}\n```\n\n---\n\n## Quickstart Test it out\nQuickstart | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/quickstart\n\n## Test it out\n\nWith everything in place, let's test the component!\n\nStart your Laravel development server if it's not already running:\n\n```shell\nphp artisan serve\n```\n\nVisit `http://localhost:8000/post/create` in your browser (or `http://yourapp.test/post/create` if using Valet, Herd, or a similar tool).\n\nYou should see a simple form with two fields and a submit button.\n\n**Try the following:**\n\n1. **Test validation:** Click \"Save Post\" without filling in any fields. You'll see red error messages appear instantly below each field—no page reload required.\n\n2. **Test submission:** Fill in both fields and click \"Save Post\". You should see a debug screen showing the values you entered.\n\nThis demonstrates Livewire's core power: reactive data binding, real-time validation, and form handling—all written in PHP without touching JavaScript.\n\n---\n\n## Lazy Full-page lazy loading\nLazy | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/lazy\n\n## Full-page lazy loading\n\nYou can lazy load or defer full-page Livewire components using route methods.\n\n### Lazy loading full pages\n\nUse `->lazy()` to load the component when it enters the viewport:\n\n```php\nRoute::livewire('/dashboard', 'pages::dashboard')->lazy();\n```\n\n### Deferring full pages\n\nUse `->defer()` to load the component immediately after the page loads:\n\n```php\nRoute::livewire('/dashboard', 'pages::dashboard')->defer();\n```\n\n### Disabling lazy/defer loading\n\nIf a component is lazy or deferred by default (via the `#[Lazy]` or `#[Defer]` attribute), you can opt-out using `enabled: false`:\n\n```php\nRoute::livewire('/dashboard', 'pages::dashboard')->lazy(enabled: false);\nRoute::livewire('/dashboard', 'pages::dashboard')->defer(enabled: false);\n```\n\n---\n\n## Validation See also\nValidation | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/validation\n\n## See also\n\n- **[Forms](/docs/4.x/forms)** — Validate form inputs with real-time feedback\n- **[Properties](/docs/4.x/properties)** — Validate property values before persisting\n- **[Validate Attribute](/docs/4.x/attribute-validate)** — Use #[Validate] for property validation\n- **[Actions](/docs/4.x/actions)** — Validate data in action methods\n\n---\n\n## Components Checkbox > Buttons\nComponents Checkbox | livewire/flux@2.x | Source: https://fluxui.dev/components/checkbox#livewire/flux\n\n
Buttons

Button-style checkbox options that look like a toolbar. Perfect for toggle controls and feature selections where you want a more prominent visual style.

<flux:checkbox.group wire:model=\"features\" label=\"Features\" variant=\"buttons\">    <flux:checkbox value=\"notifications\" icon=\"bell\" label=\"Notifications\" />    <flux:checkbox value=\"analytics\" icon=\"chart-bar\" label=\"Analytics\" />    <flux:checkbox value=\"backups\" icon=\"cloud-arrow-up\" label=\"Backups\" /></flux:checkbox.group>

\n\n---\n\n## Validation Available Validation Rules enum\nValidation | laravel/framework@12.x | Source: https://github.com/laravel/docs/blob/12.x/validation.md\n\n\n#### enum\n\nThe `Enum` rule is a class-based rule that validates whether the field under validation contains a valid enum value. The `Enum` rule accepts the name of the enum as its only constructor argument. When validating primitive values, a backed Enum should be provided to the `Enum` rule:\n\n```php\nuse App\\Enums\\ServerStatus;\nuse Illuminate\\Validation\\Rule;\n\n$request->validate([\n    'status' => [Rule::enum(ServerStatus::class)],\n]);\n```\n\nThe `Enum` rule's `only` and `except` methods may be used to limit which enum cases should be considered valid:\n\n```php\nRule::enum(ServerStatus::class)\n    ->only([ServerStatus::Pending, ServerStatus::Active]);\n\nRule::enum(ServerStatus::class)\n    ->except([ServerStatus::Pending, ServerStatus::Active]);\n```\n\nThe `when` method may be used to conditionally modify the `Enum` rule:\n\n```php\nuse Illuminate\\Support\\Facades\\Auth;\nuse Illuminate\\Validation\\Rule;\n\nRule::enum(ServerStatus::class)\n    ->when(\n        Auth::user()->isAdmin(),\n        fn ($rule) => $rule->only(...),\n        fn ($rule) => $rule->only(...),\n    );\n```\n\n---\n\n## Attribute Title Only for full-page components\nAttribute Title | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/attribute-title\n\n## Only for full-page components\n\n> [!info] Full-page components only\n> The `#[Title]` attribute only works for full-page components accessed via routes. Regular components rendered within other views don't use titles—they inherit the parent page's title.\n\n---\n\n## Quickstart Write the component\nQuickstart | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/quickstart\n\n## Write the component\n\nOpen `resources/views/pages/post/⚡create.blade.php` and replace its contents with the following:\n\n```blade\n<?php\n\nuse Livewire\\Component;\n\nnew class extends Component {\n    public string $title = '';\n\n    public string $content = '';\n\n    public function save()\n    {\n        $this->validate([\n            'title' => 'required|max:255',\n            'content' => 'required',\n        ]);\n\n        dd($this->title, $this->content);\n    }\n};\n?>\n\n<form wire:submit=\"save\">\n    <label>\n        Title\n        <input type=\"text\" wire:model=\"title\">\n        @error('title') <span style=\"color: red;\">{{ $message }}</span> @enderror\n    </label>\n\n    <label>\n        Content\n        <textarea wire:model=\"content\" rows=\"5\"></textarea>\n        @error('content') <span style=\"color: red;\">{{ $message }}</span> @enderror\n    </label>\n\n    <button type=\"submit\">Save Post</button>\n</form>\n```\n\n> [!info] Don't worry about styling\n> This form is intentionally unstyled so we can focus on Livewire's functionality. In a real application, you'd add CSS or use a framework like Tailwind.\n\nHere's what's happening in the code above:\n\n**Component properties:**\n- `public string $title = '';` — Declares a public property for the post title\n- `public string $content = '';` — Declares a public property for the post content\n\n**Component methods:**\n- `public function save()` — Called when the form is submitted. Validates the data and dumps the output for testing.\n\n**Livewire directives:**\n- `wire:submit=\"save\"` — Calls the `save()` method when the form is submitted, preventing the default page reload\n- `wire:model=\"title\"` — Creates two-way data binding between the input and the `$title` property. As you type, the property updates automatically\n- `wire:model=\"content\"` — Same two-way binding for the textarea and `$content` property\n- `@error('title')` and `@error('content')` — Display validation error messages when validation fails\n\n> [!warning] Livewire components MUST have a single root element\n> Components must have exactly one root HTML element. In this example, the `<form>` element is the single root. Multiple root elements or HTML comments outside the root element will cause an error. When rendering [full-page components](/docs/4.x/pages), named slots for the layout can be placed outside the root element.\n\n> [!tip] In a real application\n> The `save()` method uses `dd()` to dump the values for testing purposes. In a production application, you would typically save the data to a database and redirect:\n> ```php\n> public function save()\n> {\n>     $validated = $this->validate([\n>         'title' => 'required|max:255',\n>         'content' => 'required',\n>     ]);\n>\n>     Post::create($validated); // Assumes you have a Post model and database table\n>\n>     return $this->redirect('/posts');\n> }\n> ```\n\n---\n\n## Validation Deprecated `[#Rule]` attribute\nValidation | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/validation\n\n## Deprecated `[#Rule]` attribute\n\nWhen Livewire v3 first launched, it used the term \"Rule\" instead of \"Validate\" for it's validation attributes (`#[Rule]`).\n\nBecause of naming conflicts with Laravel rule objects, this has since been changed to `#[Validate]`. Both are supported in Livewire v3, however it is recommended that you change all occurrences of `#[Rule]` with `#[Validate]` to stay current.\n\n---\n\n## Components Input > With buttons\nComponents Input | livewire/flux@2.x | Source: https://fluxui.dev/components/input#livewire/flux\n\n
With buttons

Attach buttons to the beginning or end of an input element.

<flux:input.group>    <flux:input placeholder=\"Post title\" />    <flux:button icon=\"plus\">New post</flux:button></flux:input.group><flux:input.group>    <flux:select class=\"max-w-fit\">        <flux:select.option selected>USD</flux:select.option>            </flux:select>    <flux:input placeholder=\"$99.99\" /></flux:input.group>

\n\n---\n\n## Components Select > Checkbox indicator\nComponents Select | livewire/flux@2.x | Source: https://fluxui.dev/components/select#livewire/flux\n\n
\n            Checkbox indicator\n

If you prefer a checkbox indicator instead of the default checkmark icon, you can use the indicator=\"checkbox\" prop.

<flux:select variant=\"listbox\" indicator=\"checkbox\" multiple>    ...</flux:select>

\n\n---\n\n## Components Button > Full width\nComponents Button | livewire/flux@2.x | Source: https://fluxui.dev/components/button#livewire/flux\n\n
Full width

A button that spans the full width of the container.

<flux:button variant=\"primary\" class=\"w-full\">Send invite</flux:button>

\n\n---\n\n## Attribute Validate Example: Contact form\nAttribute Validate | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/attribute-validate\n\n## Example: Contact form\n\nHere's a complete contact form with validation:\n\n```php\n<?php // resources/views/pages/⚡contact.blade.php\n\nuse Livewire\\Attributes\\Validate;\nuse Livewire\\Component;\nuse App\\Mail\\ContactMessage;\nuse Illuminate\\Support\\Facades\\Mail;\n\nnew class extends Component {\n    #[Validate('required|min:2', as: 'name')]\n    public $name = '';\n\n    #[Validate('required|email')]\n    public $email = '';\n\n    #[Validate('required')]\n    public $subject = '';\n\n    #[Validate('required|min:10', as: 'message')]\n    public $message = '';\n\n    public function submit()\n    {\n        $validated = $this->validate();\n\n        Mail::to('support@example.com')->send(new ContactMessage($validated));\n\n        session()->flash('success', 'Message sent successfully!');\n\n        $this->reset();\n    }\n};\n?>\n\n<div>\n    @if (session('success'))\n        <div class=\"alert\">{{ session('success') }}</div>\n    @endif\n\n    <form wire:submit=\"submit\">\n        <div>\n            <input type=\"text\" wire:model.live.blur=\"name\" placeholder=\"Your name\">\n            @error('name') <span class=\"error\">{{ $message }}</span> @enderror\n        </div>\n\n        <div>\n            <input type=\"email\" wire:model.live.blur=\"email\" placeholder=\"Your email\">\n            @error('email') <span class=\"error\">{{ $message }}</span> @enderror\n        </div>\n\n        <div>\n            <input type=\"text\" wire:model.live.blur=\"subject\" placeholder=\"Subject\">\n            @error('subject') <span class=\"error\">{{ $message }}</span> @enderror\n        </div>\n\n        <div>\n            <textarea wire:model.live.blur=\"message\" placeholder=\"Your message\"></textarea>\n            @error('message') <span class=\"error\">{{ $message }}</span> @enderror\n        </div>\n\n        <button type=\"submit\">Send Message</button>\n    </form>\n</div>\n```\n\nUsers get immediate feedback as they fill out the form, with friendly field names and helpful error messages.\n\n---\n\n## Components Radio > Segmented with icons\nComponents Radio | livewire/flux@2.x | Source: https://fluxui.dev/components/radio#livewire/flux\n\n
Segmented with icons

Combine segmented radio buttons with icon prefixes.

<flux:radio.group wire:model=\"role\" variant=\"segmented\">    <flux:radio label=\"Admin\" icon=\"wrench\" />    <flux:radio label=\"Editor\" icon=\"pencil-square\" />    <flux:radio label=\"Viewer\" icon=\"eye\" /></flux:radio.group>

\n\n---\n\n## Validation Accessing errors in JavaScript\nValidation | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/validation\n\n## Accessing errors in JavaScript\n\nLivewire provides a `$errors` magic property for client-side access to validation errors:\n\n```blade\n<form wire:submit=\"save\">\n    <input type=\"email\" wire:model=\"email\">\n\n    <div wire:show=\"$errors.has('email')\">\n        <span wire:text=\"$errors.first('email')\"></span>\n    </div>\n\n    <button type=\"submit\">Save</button>\n</form>\n```\n\n### Available methods\n\n- `$errors.has('field')` - Check if a field has errors\n- `$errors.missing('field')` - Check if a field doesn't have errors\n- `$errors.first('field')` - Get the first error message for a field\n- `$errors.get('field')` - Get all error messages for a field\n- `$errors.all()` - Get all errors for all fields\n- `$errors.clear()` - Clear all errors\n- `$errors.clear('field')` - Clear errors for a specific field\n\nWhen using Alpine.js, access `$errors` through `$wire.$errors`.\n\n---\n\n## Validation Form objects\nValidation | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/validation\n\n## Form objects\n\nAs more properties and validation rules are added to a Livewire component, it can begin to feel too crowded. To alleviate this pain and also provide a helpful abstraction for code reuse, you can use Livewire's *Form Objects* to store your properties and validation rules.\n\nBelow is the same `CreatePost` example, but now the properties and rules have been extracted to a dedicated form object named `PostForm`:\n\n```php\n<?php\n\nnamespace App\\Livewire\\Forms;\n\nuse Livewire\\Attributes\\Validate;\nuse Livewire\\Form;\n\nclass PostForm extends Form\n{\n    #[Validate('required|min:3')]\n\tpublic $title = '';\n\n    #[Validate('required|min:3')]\n    public $content = '';\n}\n```\n\nThe `PostForm` above can now be defined as a property on the `CreatePost` component:\n\n```php\n<?php\n\nnamespace App\\Livewire;\n\nuse App\\Livewire\\Forms\\PostForm;\nuse Livewire\\Component;\nuse App\\Models\\Post;\n\nclass CreatePost extends Component\n{\n    public PostForm $form;\n\n    public function save()\n    {\n\t\tPost::create(\n    \t\t$this->form->all()\n    \t);\n\n\t\treturn redirect()->to('/posts');\n    }\n\n    // ...\n}\n```\n\nAs you can see, instead of listing out each property individually, we can retrieve all the property values using the `->all()` method on the form object.\n\nAlso, when referencing the property names in the template, you must prepend `form.` to each instance:\n\n```blade\n<form wire:submit=\"save\">\n\t<input type=\"text\" wire:model=\"form.title\">\n    <div>@error('form.title') {{ $message }} @enderror</div>\n\n\t<textarea wire:model=\"form.content\"></textarea>\n    <div>@error('form.content') {{ $message }} @enderror</div>\n\n\t<button type=\"submit\">Save</button>\n</form>\n```\n\nWhen using form objects, `#[Validate]` attribute validation will be run every time a property is updated. However, if you disable this behavior by specifying `onUpdate: false` on the attribute, you can manually run a form object's validation using `$this->form->validate()`:\n\n```php\npublic function save()\n{\n    Post::create(\n        $this->form->validate()\n    );\n\n    return redirect()->to('/posts');\n}\n```\n\nForm objects are a useful abstraction for most larger datasets and a variety of additional features that make them even more powerful. For more information, check out the comprehensive [form object documentation](/docs/4.x/forms#extracting-a-form-object).\n\n---\n\n## Validation Available Validation Rules unique:_table_,_column_\nValidation | laravel/framework@12.x | Source: https://github.com/laravel/docs/blob/12.x/validation.md\n\n\n#### unique:_table_,_column_\n\nThe field under validation must not exist within the given database table.\n\n**Specifying a Custom Table / Column Name:**\n\nInstead of specifying the table name directly, you may specify the Eloquent model which should be used to determine the table name:\n\n```php\n'email' => 'unique:App\\Models\\User,email_address'\n```\n\nThe `column` option may be used to specify the field's corresponding database column. If the `column` option is not specified, the name of the field under validation will be used.\n\n```php\n'email' => 'unique:users,email_address'\n```\n\n**Specifying a Custom Database Connection**\n\nOccasionally, you may need to set a custom connection for database queries made by the Validator. To accomplish this, you may prepend the connection name to the table name:\n\n```php\n'email' => 'unique:connection.users,email_address'\n```\n\n**Forcing a Unique Rule to Ignore a Given ID:**\n\nSometimes, you may wish to ignore a given ID during unique validation. For example, consider an \"update profile\" screen that includes the user's name, email address, and location. You will probably want to verify that the email address is unique. However, if the user only changes the name field and not the email field, you do not want a validation error to be thrown because the user is already the owner of the email address in question.\n\nTo instruct the validator to ignore the user's ID, we'll use the `Rule` class to fluently define the rule. In this example, we'll also specify the validation rules as an array instead of using the `|` character to delimit the rules:\n\n```php\nuse Illuminate\\Support\\Facades\\Validator;\nuse Illuminate\\Validation\\Rule;\n\nValidator::make($data, [\n    'email' => [\n        'required',\n        Rule::unique('users')->ignore($user->id),\n    ],\n]);\n```\n\n> [!WARNING]\n> You should never pass any user controlled request input into the `ignore` method. Instead, you should only pass a system generated unique ID such as an auto-incrementing ID or UUID from an Eloquent model instance. Otherwise, your application will be vulnerable to an SQL injection attack.\n\nInstead of passing the model key's value to the `ignore` method, you may also pass the entire model instance. Laravel will automatically extract the key from the model:\n\n```php\nRule::unique('users')->ignore($user)\n```\n\nIf your table uses a primary key column name other than `id`, you may specify the name of the column when calling the `ignore` method:\n\n```php\nRule::unique('users')->ignore($user->id, 'user_id')\n```\n\nBy default, the `unique` rule will check the uniqueness of the column matching the name of the attribute being validated. However, you may pass a different column name as the second argument to the `unique` method:\n\n```php\nRule::unique('users', 'email_address')->ignore($user->id)\n```\n\n**Adding Additional Where Clauses:**\n\nYou may specify additional query conditions by customizing the query using the `where` method. For example, let's add a query condition that scopes the query to only search records that have an `account_id` column value of `1`:\n\n```php\n'email' => Rule::unique('users')->where(fn (Builder $query) => $query->where('account_id', 1))\n```\n\n**Ignoring Soft Deleted Records in Unique Checks:**\n\nBy default, the unique rule includes soft deleted records when determining uniqueness. To exclude soft deleted records from the uniqueness check, you may invoke the `withoutTrashed` method:\n\n```php\nRule::unique('users')->withoutTrashed();\n```\n\nIf your model uses a column name other than `deleted_at` for soft deleted records, you may provide the column name when invoking the `withoutTrashed` method:\n\n```php\nRule::unique('users')->withoutTrashed('was_deleted_at');\n```\n\n---\n\n## Search Full-Text Search Running Full-Text Queries\nSearch | laravel/framework@12.x | Source: https://github.com/laravel/docs/blob/12.x/search.md\n\n\n### Running Full-Text Queries\n\nOnce the index is in place, use the `whereFullText` query builder method to search against it. Laravel will generate the appropriate SQL for your database driver — for example, `MATCH(...) AGAINST(...)` on MariaDB and MySQL, and `to_tsvector(...) @@ plainto_tsquery(...)` on PostgreSQL:\n\n```php\n$articles = Article::whereFullText('body', 'web developer')->get();\n```\n\nWhen using MariaDB and MySQL, results are automatically ordered by relevance score. On PostgreSQL, `whereFullText` filters matching records but does not order them by relevance — if you need automatic relevance ordering on PostgreSQL, consider using [Scout's database engine](#database-engine), which handles this for you.\n\nIf you created a composite full-text index across multiple columns, you may search against all of them by passing the same array of columns to `whereFullText`:\n\n```php\n$articles = Article::whereFullText(\n    ['title', 'body'], 'web developer'\n)->get();\n```\n\nThe `orWhereFullText` method may be used to add a full-text search clause as an \"or\" condition. For complete details, consult the [query builder documentation](/docs/{{version}}/queries#full-text-where-clauses).\n\n---\n\n## Components Field > With badge\nComponents Field | livewire/flux@2.x | Source: https://fluxui.dev/components/field#livewire/flux\n\n
With badge

Badges allow you to enhance a field with additional information such as being \"required\" or \"optional\" when it might not be expected.

<flux:field>    <flux:label badge=\"Required\">Email</flux:label>    <flux:input type=\"email\" required />    <flux:error name=\"email\" /></flux:field><flux:field>    <flux:label badge=\"Optional\">Phone number</flux:label>    <flux:input type=\"phone\" placeholder=\"(555) 555-5555\" mask=\"(999) 999-9999\"  />    <flux:error name=\"phone\" /></flux:field>

\n\n---\n\n## Forms See also\nForms | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/forms\n\n## See also\n\n- **[Validation](/docs/4.x/validation)** — Validate form inputs with real-time feedback\n- **[wire:model](/docs/4.x/wire-model)** — Bind form inputs to component properties\n- **[File Uploads](/docs/4.x/uploads)** — Handle file uploads in forms\n- **[Actions](/docs/4.x/actions)** — Process form submissions with actions\n- **[Loading States](/docs/4.x/loading-states)** — Show loading indicators during form submission\n\n---\n\n## Validation Testing validation\nValidation | livewire/livewire@4.x | Source: https://livewire.laravel.com/docs/4.x/validation\n\n## Testing validation\n\nLivewire provides useful testing utilities for validation scenarios, such as the `assertHasErrors()` method.\n\nBelow is a basic test case that ensures validation errors are thrown if no input is set for the `title` property:\n\n```php\n<?php\n\nnamespace Tests\\Feature\\Livewire;\n\nuse App\\Livewire\\CreatePost;\nuse Livewire\\Livewire;\nuse Tests\\TestCase;\n\nclass CreatePostTest extends TestCase\n{\n    public function test_cant_create_post_without_title()\n    {\n        Livewire::test(CreatePost::class)\n            ->set('content', 'Sample content...')\n            ->call('save')\n            ->assertHasErrors('title');\n    }\n}\n```\n\nIn addition to testing the presence of errors, `assertHasErrors` allows you to also narrow down the assertion to specific rules by passing the rules to assert against as the second argument to the method:\n\n```php\npublic function test_cant_create_post_with_title_shorter_than_3_characters()\n{\n    Livewire::test(CreatePost::class)\n        ->set('title', 'Sa')\n        ->set('content', 'Sample content...')\n        ->call('save')\n        ->assertHasErrors(['title' => ['min:3']]);\n}\n```\n\nYou can also assert the presence of validation errors for multiple properties at the same time:\n\n```php\npublic function test_cant_create_post_without_title_and_content()\n{\n    Livewire::test(CreatePost::class)\n        ->call('save')\n        ->assertHasErrors(['title', 'content']);\n}\n```\n\nFor more information on other testing utilities provided by Livewire, check out the [testing documentation](/docs/4.x/testing).\n\n_[Truncated]_"}]


command: sed -n '1,260p' database/factories/DiscountFactory.php

DiscountFactory.php

type: read

aggregated_output:
<?php

namespace Database\Factories;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Models\Store;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Discount>
 */
class DiscountFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'store_id' => Store::factory(),
            'type' => DiscountType::Code,
            'code' => fake()->unique()->bothify('SAVE##'),
            'value_type' => DiscountValueType::Percent,
            'value_amount' => 10,
            'starts_at' => now()->subDay(),
            'ends_at' => now()->addMonth(),
            'usage_limit' => null,
            'usage_count' => 0,
            'rules_json' => ['customer_eligibility' => 'all'],
            'status' => DiscountStatus::Active,
        ];
    }

    public function fixed(int $amount = 500): static
    {
        return $this->state(fn (array $attributes): array => [
            'value_type' => DiscountValueType::Fixed,
            'value_amount' => $amount,
        ]);
    }

    public function freeShipping(): static
    {
        return $this->state(fn (array $attributes): array => [
            'value_type' => DiscountValueType::FreeShipping,
            'value_amount' => 0,
        ]);
    }
}

status: completed


command:
/bin/zsh
-lc
sed -n '1,260p' app/Models/Discount.php

Discount.php

cmd: sed -n '1,260p' app/Models/Discount.php

aggregated_output:
<?php

namespace App\Models;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Discount extends Model
{
    /** @use HasFactory<\Database\Factories\DiscountFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'type',
        'code',
        'value_type',
        'value_amount',
        'starts_at',
        'ends_at',
        'usage_limit',
        'usage_count',
        'rules_json',
        'status',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'code',
        'value_amount' => 0,
        'usage_count' => 0,
        'rules_json' => '{}',
        'status' => 'active',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => DiscountType::class,
            'value_type' => DiscountValueType::class,
            'value_amount' => 'integer',
            'starts_at' => 'datetime',
            'ends_at' => 'datetime',
            'usage_limit' => 'integer',
            'usage_count' => 'integer',
            'rules_json' => 'array',
            'status' => DiscountStatus::class,
        ];
    }
}


command: sed -n '1,240p' database/migrations/2026_05_03_225427_create_discounts_table.php

aggregated_output:
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('discounts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('store_id')->constrained()->cascadeOnDelete();
            $table->enum('type', ['code', 'automatic'])->default('code');
            $table->string('code')->nullable();
            $table->enum('value_type', ['fixed', 'percent', 'free_shipping']);
            $table->integer('value_amount')->default(0);
            $table->timestamp('starts_at');
            $table->timestamp('ends_at')->nullable();
            $table->unsignedInteger('usage_limit')->nullable();
            $table->unsignedInteger('usage_count')->default(0);
            $table->text('rules_json')->default('{}');
            $table->enum('status', ['draft', 'active', 'expired', 'disabled'])->default('active');
            $table->timestamps();

            $table->unique(['store_id', 'code']);
            $table->index('store_id');
            $table->index(['store_id', 'status']);
            $table->index(['store_id', 'type']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('discounts');
    }
};


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

namespace App\Models;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Models\Concerns\BelongsToStore;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Discount extends Model
{
    /** @use HasFactory<\Database\Factories\DiscountFactory> */
    use BelongsToStore, HasFactory;

    /**
     * @var list<string>
     */
    protected $fillable = [
        'store_id',
        'type',
        'code',
        'value_type',
        'value_amount',
        'starts_at',
        'ends_at',
        'usage_limit',
        'usage_count',
        'rules_json',
        'status',
    ];

    /**
     * @var array<string, mixed>
     */
    protected $attributes = [
        'type' => 'code',
        'value_amount' => 0,
        'usage_count' => 0,
        'rules_json' => '{}',
        'status' => 'active',
    ];

    /**
     * @return BelongsTo<Store, $this>
     */
    public function store(): BelongsTo
    {
        return $this->belongsTo(Store::class);
    }

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'type' => DiscountType::class,
            'value_type' => DiscountValueType::class,
            'value_amount' => 'integer',
            'starts_at' => 'datetime',
            'ends_at' => 'datetime',
            'usage_limit' => 'integer',
            'usage_count' => 'integer',
            'rules_json' => 'array',
            'status' => DiscountStatus::class,
        ];
    }
}


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

namespace Database\Factories;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Models\Store;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Discount>
 */
class DiscountFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'store_id' => Store::factory(),
            'type' => DiscountType::Code,
            'code' => fake()->unique()->bothify('SAVE##'),
            'value_type' => DiscountValueType::Percent,
            'value_amount' => 10,
            'starts_at' => now()->subDay(),
            'ends_at' => now()->addMonth(),
            'usage_limit' => null,
            'usage_count' => 0,
            'rules_json' => ['customer_eligibility' => 'all'],
            'status' => DiscountStatus::Active,
        ];
    }

    public function fixed(int $amount = 500): static
    {
        return $this->state(fn (array $attributes): array => [
            'value_type' => DiscountValueType::Fixed,
            'value_amount' => $amount,
        ]);
    }

    public function freeShipping(): static
    {
        return $this->state(fn (array $attributes): array => [
            'value_type' => DiscountValueType::FreeShipping,
            'value_amount' => 0,
        ]);
    }
}


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

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('discounts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('store_id')->constrained()->cascadeOnDelete();
            $table->enum('type', ['code', 'automatic'])->default('code');
            $table->string('code')->nullable();
            $table->enum('value_type', ['fixed', 'percent', 'free_shipping']);
            $table->integer('value_amount')->default(0);
            $table->timestamp('starts_at');
            $table->timestamp('ends_at')->nullable();
            $table->unsignedInteger('usage_limit')->nullable();
            $table->unsignedInteger('usage_count')->default(0);
            $table->text('rules_json')->default('{}');
            $table->enum('status', ['draft', 'active', 'expired', 'disabled'])->default('active');
            $table->timestamps();

            $table->unique(['store_id', 'code']);
            $table->index('store_id');
            $table->index(['store_id', 'status']);
            $table->index(['store_id', 'type']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('discounts');
    }
};


cmd: sed -n '1,120p' app/Enums/DiscountType.php


cmd: sed -n '1,120p' app/Enums/DiscountValueType.php


cmd: sed -n '1,120p' app/Enums/DiscountStatus.php


cmd: sed -n '1,260p' app/Services/DiscountService.php


cmd: rg -n "rules_json|minimum|specific|collection|one_per|customer" app tests database/seeders/DiscountSeeder.php


command: sed -n '1,120p' app/Enums/DiscountType.php

aggregated_output:
<?php

namespace App\Enums;

enum DiscountType: string
{
    case Code = 'code';
    case Automatic = 'automatic';
}


command: sed -n '1,120p' app/Enums/DiscountValueType.php

aggregated_output:
<?php

namespace App\Enums;

enum DiscountValueType: string
{
    case Percent = 'percent';
    case Fixed = 'fixed';
    case FreeShipping = 'free_shipping';
}


command: sed -n '1,120p' app/Enums/DiscountStatus.php

aggregated_output:
<?php

namespace App\Enums;

enum DiscountStatus: string
{
    case Draft = 'draft';
    case Active = 'active';
    case Expired = 'expired';
    case Disabled = 'disabled';
}


command: sed -n '1,260p' app/Services/DiscountService.php

aggregated_output:
<?php

namespace App\Services;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Exceptions\InvalidDiscountException;
use App\Models\Cart;
use App\Models\CartLine;
use App\Models\Discount;
use App\Models\ProductVariant;
use App\Models\Store;
use App\ValueObjects\DiscountResult;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

class DiscountService
{
    public function validate(string $code, Store $store, Cart $cart): Discount
    {
        $normalizedCode = mb_strtolower(trim($code));

        $discount = Discount::withoutGlobalScopes()
            ->where('store_id', $store->getKey())
            ->where('type', DiscountType::Code)
            ->whereRaw('lower(code) = ?', [$normalizedCode])
            ->first();

        if (! $discount instanceof Discount) {
            throw InvalidDiscountException::because('discount_not_found', 'Discount code was not found.');
        }

        if ($discount->status !== DiscountStatus::Active) {
            throw InvalidDiscountException::because('discount_expired', 'Discount is not active.');
        }

        if ($discount->starts_at->isFuture()) {
            throw InvalidDiscountException::because('discount_not_yet_active', 'Discount is not active yet.');
        }

        if ($discount->ends_at !== null && $discount->ends_at->isPast()) {
            throw InvalidDiscountException::because('discount_expired', 'Discount has expired.');
        }

        if ($discount->usage_limit !== null && $discount->usage_count >= $discount->usage_limit) {
            throw InvalidDiscountException::because('discount_usage_limit_reached', 'Discount usage limit has been reached.');
        }

        $lines = $this->cartLines($cart);
        $subtotal = $lines->sum('line_subtotal_amount');
        $minimum = (int) data_get($discount->rules_json, 'min_purchase_amount', data_get($discount->rules_json, 'minimum_purchase', 0));

        if ($minimum > 0 && $subtotal < $minimum) {
            throw InvalidDiscountException::because('discount_min_purchase_not_met', 'Cart does not meet the minimum purchase amount.');
        }

        if ($this->qualifyingLines($discount, $lines)->isEmpty()) {
            throw InvalidDiscountException::because('discount_not_applicable', 'Discount does not apply to these cart lines.');
        }

        return $discount;
    }

    /**
     * @param  array<int, CartLine>  $lines
     */
    public function calculate(Discount $discount, int $subtotal, array $lines): DiscountResult
    {
        if ($discount->value_type === DiscountValueType::FreeShipping) {
            return new DiscountResult(0, [], true);
        }

        $qualifyingLines = $this->qualifyingLines($discount, collect($lines));
        $qualifyingSubtotal = $qualifyingLines->sum('line_subtotal_amount');

        if ($qualifyingSubtotal <= 0) {
            return new DiscountResult(0, []);
        }

        $discountAmount = match ($discount->value_type) {
            DiscountValueType::Percent => (int) round($qualifyingSubtotal * $discount->value_amount / 100),
            DiscountValueType::Fixed => min($discount->value_amount, $qualifyingSubtotal),
            DiscountValueType::FreeShipping => 0,
        };

        $remaining = $discountAmount;
        $allocations = [];
        $lastIndex = $qualifyingLines->keys()->last();

        foreach ($qualifyingLines as $index => $line) {
            if ($index === $lastIndex) {
                $allocations[$line->getKey()] = $remaining;

                continue;
            }

            $allocation = (int) round($discountAmount * $line->line_subtotal_amount / $qualifyingSubtotal);
            $allocations[$line->getKey()] = $allocation;
            $remaining -= $allocation;
        }

        return new DiscountResult($discountAmount, $allocations);
    }

    public function applyToCart(Cart $cart, Discount $discount): DiscountResult
    {
        return DB::transaction(function () use ($cart, $discount): DiscountResult {
            $lines = $this->cartLines($cart);
            $result = $this->calculate($discount, $lines->sum('line_subtotal_amount'), $lines->all());

            $lines->each(function (CartLine $line) use ($result): void {
                $discountAmount = $result->allocations[$line->getKey()] ?? 0;

                $line->forceFill([
                    'line_discount_amount' => $discountAmount,
                    'line_total_amount' => $line->line_subtotal_amount - $discountAmount,
                ])->save();
            });

            return $result;
        });
    }

    /**
     * @return Collection<int, CartLine>
     */
    private function cartLines(Cart $cart): Collection
    {
        return CartLine::withoutGlobalScopes()
            ->where('cart_id', $cart->getKey())
            ->orderBy('id')
            ->get();
    }

    /**
     * @param  Collection<int, CartLine>  $lines
     * @return Collection<int, CartLine>
     */
    private function qualifyingLines(Discount $discount, Collection $lines): Collection
    {
        $productIds = collect(data_get($discount->rules_json, 'applicable_product_ids', []))
            ->filter()
            ->map(fn (mixed $id): int => (int) $id)
            ->values();
        $collectionIds = collect(data_get($discount->rules_json, 'applicable_collection_ids', []))
            ->filter()
            ->map(fn (mixed $id): int => (int) $id)
            ->values();

        if ($productIds->isEmpty() && $collectionIds->isEmpty()) {
            return $lines;
        }

        return $lines->filter(function (CartLine $line) use ($productIds, $collectionIds): bool {
            $variant = ProductVariant::withoutGlobalScopes()
                ->with(['product' => fn ($query) => $query->withoutGlobalScopes()->with('collections')])
                ->find($line->variant_id);

            if (! $variant instanceof ProductVariant || $variant->product === null) {
                return false;
            }

            if ($productIds->contains((int) $variant->product_id)) {
                return true;
            }

            return $variant->product->collections
                ->pluck('id')
                ->map(fn (int $id): int => $id)
                ->intersect($collectionIds)
                ->isNotEmpty();
        });
    }
}


command: rg -n "rules_json|minimum|specific|collection|one_per|customer" app tests database/seeders/DiscountSeeder.php

type: search

cmd: rg -n 'rules_json|minimum|specific|collection|one_per|customer' app tests database/seeders/DiscountSeeder.php

query: rules_json|minimum|specific|collection|one_per|customer

path: app

aggregated_output:
database/seeders/DiscountSeeder.php:31:                        'rules_json' => $discount['rules_json'],
database/seeders/DiscountSeeder.php:40:     * @return array<int, array{code: string, value_type: string, value_amount: int, rules_json: array<string, mixed>}>
database/seeders/DiscountSeeder.php:45:            ['code' => 'SAVE10', 'value_type' => 'percent', 'value_amount' => 10, 'rules_json' => ['customer_eligibility' => 'all']],
database/seeders/DiscountSeeder.php:46:            ['code' => '5OFF', 'value_type' => 'fixed', 'value_amount' => 500, 'rules_json' => ['min_purchase_amount' => 2500, 'customer_eligibility' => 'all']],
database/seeders/DiscountSeeder.php:47:            ['code' => 'FREESHIP', 'value_type' => 'free_shipping', 'value_amount' => 0, 'rules_json' => ['customer_eligibility' => 'all']],
tests/Pest.php:8:| The closure you provide to your test functions is always bound to a specific PHPUnit test
tests/Pest.php:38:| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
tests/Feature/Catalog/CatalogFoundationTest.php:24:        ->and(Schema::hasColumns('collections', ['store_id', 'title', 'handle', 'type', 'status']))->toBeTrue()
tests/Feature/Catalog/CatalogUiTest.php:31:        ->get('/collections/t-shirts')
tests/Feature/Catalog/CatalogUiTest.php:63:        ->get('/admin/collections')
tests/Feature/Catalog/CatalogUiTest.php:154:test('admin collection form creates and assigns products', function () {
tests/Feature/Catalog/CatalogUiTest.php:163:        ->set('handle', 'e2e-test-collection')
tests/Feature/Catalog/CatalogUiTest.php:169:    $collection = Collection::query()->where('handle', 'e2e-test-collection')->firstOrFail();
tests/Feature/Catalog/CatalogUiTest.php:171:    expect($collection->products()->pluck('products.id')->all())->toBe([$product->getKey()]);
tests/Feature/Cart/CartServiceTest.php:107:test('cart service allows oversell for continue policy and merges guest carts into customer carts', function () {
tests/Feature/Cart/CartServiceTest.php:113:    $customer = Customer::factory()->create(['store_id' => $store->getKey()]);
tests/Feature/Cart/CartServiceTest.php:114:    $customerCart = $service->create($store, $customer);
tests/Feature/Cart/CartServiceTest.php:117:    $service->addLine($customerCart, $firstVariant->getKey(), 2);
tests/Feature/Cart/CartServiceTest.php:118:    $service->addLine($customerCart, $secondVariant->getKey(), 3);
tests/Feature/Cart/CartServiceTest.php:120:    $merged = $service->mergeOnLogin($guestCart, $customerCart);
tests/Feature/Foundation/CustomerAuthTest.php:13:test('customer authentication is scoped to the current store', function () {
tests/Feature/Foundation/CustomerAuthTest.php:31:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:36:    Auth::guard('customer')->logout();
tests/Feature/Foundation/CustomerAuthTest.php:38:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:45:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:51:test('customer login component authenticates within the resolved store', function () {
tests/Feature/Foundation/CustomerAuthTest.php:53:    $customer = Customer::factory()->create([
tests/Feature/Foundation/CustomerAuthTest.php:55:        'email' => 'customer@example.test',
tests/Feature/Foundation/CustomerAuthTest.php:62:        ->set('email', $customer->email)
tests/Feature/Foundation/CustomerAuthTest.php:68:    $this->assertAuthenticatedAs($customer, 'customer');
tests/Feature/Foundation/CustomerAuthTest.php:71:test('customer registration is unique per store', function () {
tests/Feature/Storefront/OrderViewsTest.php:126:test('order confirmation is visible only for the session order or customer order', function () {
tests/Feature/Storefront/OrderViewsTest.php:128:    $customer = Customer::withoutGlobalScopes()->where('store_id', $store->getKey())->firstOrFail();
tests/Feature/Storefront/OrderViewsTest.php:130:    $order = Order::factory()->forCustomer($customer)->paid()->create([
tests/Feature/Storefront/OrderViewsTest.php:132:        'customer_id' => $customer->getKey(),
tests/Feature/Storefront/OrderViewsTest.php:133:        'email' => $customer->email,
tests/Feature/Storefront/OrderViewsTest.php:146:    $this->actingAs($otherCustomer, 'customer');
tests/Feature/Storefront/OrderViewsTest.php:151:    $this->actingAs($customer, 'customer');
tests/Feature/Storefront/OrderViewsTest.php:157:test('customer account lists and shows customer orders', function () {
tests/Feature/Storefront/OrderViewsTest.php:159:    $customer = Customer::withoutGlobalScopes()->where('store_id', $store->getKey())->firstOrFail();
tests/Feature/Storefront/OrderViewsTest.php:161:    $order = Order::factory()->forCustomer($customer)->paid()->create([
tests/Feature/Storefront/OrderViewsTest.php:163:        'customer_id' => $customer->getKey(),
tests/Feature/Storefront/OrderViewsTest.php:168:    …20044 chars truncated…wire/Storefront/Products/Show.php:109:            ->with(['options.values', 'variants.inventoryItem', 'variants.optionValues.option', 'collections'])
app/Services/ThemeSettingsService.php:71:                    'primary_url' => '/collections/new-arrivals',
app/Services/ThemeSettingsService.php:72:                    'secondary_label' => 'View collections',
app/Services/ThemeSettingsService.php:73:                    'secondary_url' => '/collections',
app/Services/ThemeSettingsService.php:76:                'featured_collection_limit' => 4,
app/Livewire/Storefront/Account/Auth/Login.php:40:        $key = 'customer-login:'.request()->ip();
app/Livewire/Storefront/Account/Auth/Login.php:52:        if (! Auth::guard('customer')->attempt([
app/Livewire/Storefront/Account/Auth/Login.php:69:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Account/Auth/Login.php:71:        if ($customer instanceof Customer && session()->has('cart_id')) {
app/Livewire/Storefront/Account/Auth/Login.php:72:            app(CartService::class)->getOrCreateForSession(Store::query()->findOrFail($this->storeId), $customer);
app/Models/CustomerAddress.php:20:        'customer_id',
app/Models/CustomerAddress.php:29:    public function customer(): BelongsTo
app/Livewire/Storefront/Home.php:41:            ->limit((int) data_get($this->themeSettings(), 'home.featured_collection_limit', 4))
app/Livewire/Storefront/Checkout/Show.php:82:        $this->email = $this->customer()?->email ?? '';
app/Livewire/Storefront/Checkout/Show.php:271:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/Checkout/Show.php:294:            $checkout = app(CheckoutService::class)->createFromCart($cart, $this->customer());
app/Livewire/Storefront/Checkout/Show.php:390:    private function customer(): ?Customer
app/Livewire/Storefront/Checkout/Show.php:392:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Checkout/Show.php:394:        return $customer instanceof Customer ? $customer : null;
app/Livewire/Storefront/Cart/Show.php:158:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/Cart/Show.php:286:    private function customer(): ?Customer
app/Livewire/Storefront/Cart/Show.php:288:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Cart/Show.php:290:        return $customer instanceof Customer ? $customer : null;
app/Livewire/Storefront/CartDrawer.php:90:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/CartDrawer.php:126:    private function customer(): ?Customer
app/Livewire/Storefront/CartDrawer.php:128:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/CartDrawer.php:130:        return $customer instanceof Customer ? $customer : null;
app/Models/Discount.php:31:        'rules_json',
app/Models/Discount.php:42:        'rules_json' => '{}',
app/Models/Discount.php:67:            'rules_json' => 'array',
app/Models/Order.php:26:        'customer_id',
app/Models/Order.php:78:    public function customer(): BelongsTo
app/Models/Cart.php:22:        'customer_id',
app/Models/Cart.php:48:    public function customer(): BelongsTo
app/Models/Product.php:76:    public function collections(): BelongsToMany
app/Models/Product.php:78:        return $this->belongsToMany(Collection::class, 'collection_products')
app/Models/Checkout.php:22:        'customer_id',
app/Models/Checkout.php:61:    public function customer(): BelongsTo
app/Models/Collection.php:51:        return $this->belongsToMany(Product::class, 'collection_products')
app/Http/Resources/Admin/V1/OrderResource.php:22:            'customer' => $this->whenLoaded('customer', fn () => $this->customer ? [
app/Http/Resources/Admin/V1/OrderResource.php:23:                'id' => $this->customer->id,
app/Http/Resources/Admin/V1/OrderResource.php:24:                'name' => $this->customer->name,
app/Http/Resources/Admin/V1/OrderResource.php:25:                'email' => $this->customer->email,
app/Http/Resources/Admin/V1/OrderResource.php:57:            'refunds' => RefundResource::collection($this->whenLoaded('refunds')),
app/Http/Resources/Admin/V1/OrderResource.php:58:            'fulfillments' => FulfillmentResource::collection($this->whenLoaded('fulfillments')),
app/Enums/NavigationItemType.php:9:    case Collection = 'collection';
app/Http/Resources/Storefront/V1/CartResource.php:22:            'customer_id' => $this->customer_id,
app/Http/Resources/Storefront/V1/CartResource.php:33:            'lines' => CartLineResource::collection($lines),
app/Http/Resources/Storefront/V1/CheckoutResource.php:21:            'customer_id' => $this->customer_id,
app/Http/Resources/Storefront/V1/CheckoutResource.php:31:            'available_shipping_rates' => ShippingRateResource::collection($this->whenLoaded('availableRates')),


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

namespace App\Enums;

enum DiscountType: string
{
    case Code = 'code';
    case Automatic = 'automatic';
}


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

namespace App\Enums;

enum DiscountValueType: string
{
    case Percent = 'percent';
    case Fixed = 'fixed';
    case FreeShipping = 'free_shipping';
}


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

namespace App\Enums;

enum DiscountStatus: string
{
    case Draft = 'draft';
    case Active = 'active';
    case Expired = 'expired';
    case Disabled = 'disabled';
}


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

namespace App\Services;

use App\Enums\DiscountStatus;
use App\Enums\DiscountType;
use App\Enums\DiscountValueType;
use App\Exceptions\InvalidDiscountException;
use App\Models\Cart;
use App\Models\CartLine;
use App\Models\Discount;
use App\Models\ProductVariant;
use App\Models\Store;
use App\ValueObjects\DiscountResult;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

class DiscountService
{
    public function validate(string $code, Store $store, Cart $cart): Discount
    {
        $normalizedCode = mb_strtolower(trim($code));

        $discount = Discount::withoutGlobalScopes()
            ->where('store_id', $store->getKey())
            ->where('type', DiscountType::Code)
            ->whereRaw('lower(code) = ?', [$normalizedCode])
            ->first();

        if (! $discount instanceof Discount) {
            throw InvalidDiscountException::because('discount_not_found', 'Discount code was not found.');
        }

        if ($discount->status !== DiscountStatus::Active) {
            throw InvalidDiscountException::because('discount_expired', 'Discount is not active.');
        }

        if ($discount->starts_at->isFuture()) {
            throw InvalidDiscountException::because('discount_not_yet_active', 'Discount is not active yet.');
        }

        if ($discount->ends_at !== null && $discount->ends_at->isPast()) {
            throw InvalidDiscountException::because('discount_expired', 'Discount has expired.');
        }

        if ($discount->usage_limit !== null && $discount->usage_count >= $discount->usage_limit) {
            throw InvalidDiscountException::because('discount_usage_limit_reached', 'Discount usage limit has been reached.');
        }

        $lines = $this->cartLines($cart);
        $subtotal = $lines->sum('line_subtotal_amount');
        $minimum = (int) data_get($discount->rules_json, 'min_purchase_amount', data_get($discount->rules_json, 'minimum_purchase', 0));

        if ($minimum > 0 && $subtotal < $minimum) {
            throw InvalidDiscountException::because('discount_min_purchase_not_met', 'Cart does not meet the minimum purchase amount.');
        }

        if ($this->qualifyingLines($discount, $lines)->isEmpty()) {
            throw InvalidDiscountException::because('discount_not_applicable', 'Discount does not apply to these cart lines.');
        }

        return $discount;
    }

    /**
     * @param  array<int, CartLine>  $lines
     */
    public function calculate(Discount $discount, int $subtotal, array $lines): DiscountResult
    {
        if ($discount->value_type === DiscountValueType::FreeShipping) {
            return new DiscountResult(0, [], true);
        }

        $qualifyingLines = $this->qualifyingLines($discount, collect($lines));
        $qualifyingSubtotal = $qualifyingLines->sum('line_subtotal_amount');

        if ($qualifyingSubtotal <= 0) {
            return new DiscountResult(0, []);
        }

        $discountAmount = match ($discount->value_type) {
            DiscountValueType::Percent => (int) round($qualifyingSubtotal * $discount->value_amount / 100),
            DiscountValueType::Fixed => min($discount->value_amount, $qualifyingSubtotal),
            DiscountValueType::FreeShipping => 0,
        };

        $remaining = $discountAmount;
        $allocations = [];
        $lastIndex = $qualifyingLines->keys()->last();

        foreach ($qualifyingLines as $index => $line) {
            if ($index === $lastIndex) {
                $allocations[$line->getKey()] = $remaining;

                continue;
            }

            $allocation = (int) round($discountAmount * $line->line_subtotal_amount / $qualifyingSubtotal);
            $allocations[$line->getKey()] = $allocation;
            $remaining -= $allocation;
        }

        return new DiscountResult($discountAmount, $allocations);
    }

    public function applyToCart(Cart $cart, Discount $discount): DiscountResult
    {
        return DB::transaction(function () use ($cart, $discount): DiscountResult {
            $lines = $this->cartLines($cart);
            $result = $this->calculate($discount, $lines->sum('line_subtotal_amount'), $lines->all());

            $lines->each(function (CartLine $line) use ($result): void {
                $discountAmount = $result->allocations[$line->getKey()] ?? 0;

                $line->forceFill([
                    'line_discount_amount' => $discountAmount,
                    'line_total_amount' => $line->line_subtotal_amount - $discountAmount,
                ])->save();
            });

            return $result;
        });
    }

    /**
     * @return Collection<int, CartLine>
     */
    private function cartLines(Cart $cart): Collection
    {
        return CartLine::withoutGlobalScopes()
            ->where('cart_id', $cart->getKey())
            ->orderBy('id')
            ->get();
    }

    /**
     * @param  Collection<int, CartLine>  $lines
     * @return Collection<int, CartLine>
     */
    private function qualifyingLines(Discount $discount, Collection $lines): Collection
    {
        $productIds = collect(data_get($discount->rules_json, 'applicable_product_ids', []))
            ->filter()
            ->map(fn (mixed $id): int => (int) $id)
            ->values();
        $collectionIds = collect(data_get($discount->rules_json, 'applicable_collection_ids', []))
            ->filter()
            ->map(fn (mixed $id): int => (int) $id)
            ->values();

        if ($productIds->isEmpty() && $collectionIds->isEmpty()) {
            return $lines;
        }

        return $lines->filter(function (CartLine $line) use ($productIds, $collectionIds): bool {
            $variant = ProductVariant::withoutGlobalScopes()
                ->with(['product' => fn ($query) => $query->withoutGlobalScopes()->with('collections')])
                ->find($line->variant_id);

            if (! $variant instanceof ProductVariant || $variant->product === null) {
                return false;
            }

            if ($productIds->contains((int) $variant->product_id)) {
                return true;
            }

            return $variant->product->collections
                ->pluck('id')
                ->map(fn (int $id): int => $id)
                ->intersect($collectionIds)
                ->isNotEmpty();
        });
    }
}


output:
Chunk ID: 7b076f
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 7511
Output:
database/seeders/DiscountSeeder.php:31:                        'rules_json' => $discount['rules_json'],
database/seeders/DiscountSeeder.php:40:     * @return array<int, array{code: string, value_type: string, value_amount: int, rules_json: array<string, mixed>}>
database/seeders/DiscountSeeder.php:45:            ['code' => 'SAVE10', 'value_type' => 'percent', 'value_amount' => 10, 'rules_json' => ['customer_eligibility' => 'all']],
database/seeders/DiscountSeeder.php:46:            ['code' => '5OFF', 'value_type' => 'fixed', 'value_amount' => 500, 'rules_json' => ['min_purchase_amount' => 2500, 'customer_eligibility' => 'all']],
database/seeders/DiscountSeeder.php:47:            ['code' => 'FREESHIP', 'value_type' => 'free_shipping', 'value_amount' => 0, 'rules_json' => ['customer_eligibility' => 'all']],
tests/Pest.php:8:| The closure you provide to your test functions is always bound to a specific PHPUnit test
tests/Pest.php:38:| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
tests/Feature/Catalog/CatalogFoundationTest.php:24:        ->and(Schema::hasColumns('collections', ['store_id', 'title', 'handle', 'type', 'status']))->toBeTrue()
tests/Feature/Catalog/CatalogUiTest.php:31:        ->get('/collections/t-shirts')
tests/Feature/Catalog/CatalogUiTest.php:63:        ->get('/admin/collections')
tests/Feature/Catalog/CatalogUiTest.php:154:test('admin collection form creates and assigns products', function () {
tests/Feature/Catalog/CatalogUiTest.php:163:        ->set('handle', 'e2e-test-collection')
tests/Feature/Catalog/CatalogUiTest.php:169:    $collection = Collection::query()->where('handle', 'e2e-test-collection')->firstOrFail();
tests/Feature/Catalog/CatalogUiTest.php:171:    expect($collection->products()->pluck('products.id')->all())->toBe([$product->getKey()]);
tests/Feature/Cart/CartServiceTest.php:107:test('cart service allows oversell for continue policy and merges guest carts into customer carts', function () {
tests/Feature/Cart/CartServiceTest.php:113:    $customer = Customer::factory()->create(['store_id' => $store->getKey()]);
tests/Feature/Cart/CartServiceTest.php:114:    $customerCart = $service->create($store, $customer);
tests/Feature/Cart/CartServiceTest.php:117:    $service->addLine($customerCart, $firstVariant->getKey(), 2);
tests/Feature/Cart/CartServiceTest.php:118:    $service->addLine($customerCart, $secondVariant->getKey(), 3);
tests/Feature/Cart/CartServiceTest.php:120:    $merged = $service->mergeOnLogin($guestCart, $customerCart);
tests/Feature/Foundation/CustomerAuthTest.php:13:test('customer authentication is scoped to the current store', function () {
tests/Feature/Foundation/CustomerAuthTest.php:31:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:36:    Auth::guard('customer')->logout();
tests/Feature/Foundation/CustomerAuthTest.php:38:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:45:    expect(Auth::guard('customer')->attempt([
tests/Feature/Foundation/CustomerAuthTest.php:51:test('customer login component authenticates within the resolved store', function () {
tests/Feature/Foundation/CustomerAuthTest.php:53:    $customer = Customer::factory()->create([
tests/Feature/Foundation/CustomerAuthTest.php:55:        'email' => 'customer@example.test',
tests/Feature/Foundation/CustomerAuthTest.php:62:        ->set('email', $customer->email)
tests/Feature/Foundation/CustomerAuthTest.php:68:    $this->assertAuthenticatedAs($customer, 'customer');
tests/Feature/Foundation/CustomerAuthTest.php:71:test('customer registration is unique per store', function () {
tests/Feature/Storefront/OrderViewsTest.php:126:test('order confirmation is visible only for the session order or customer order', function () {
tests/Feature/Storefront/OrderViewsTest.php:128:    $customer = Customer::withoutGlobalScopes()->where('store_id', $store->getKey())->firstOrFail();
tests/Feature/Storefront/OrderViewsTest.php:130:    $order = Order::factory()->forCustomer($customer)->paid()->create([
tests/Feature/Storefront/OrderViewsTest.php:132:        'customer_id' => $customer->getKey(),
tests/Feature/Storefront/OrderViewsTest.php:133:        'email' => $customer->email,
tests/Feature/Storefront/OrderViewsTest.php:146:    $this->actingAs($otherCustomer, 'customer');
tests/Feature/Storefront/OrderViewsTest.php:151:    $this->actingAs($customer, 'customer');
tests/Feature/Storefront/OrderViewsTest.php:157:test('customer account lists and shows customer orders', function () {
tests/Feature/Storefront/OrderViewsTest.php:159:    $customer = Customer::withoutGlobalScopes()->where('store_id', $store->getKey())->firstOrFail();
tests/Feature/Storefront/OrderViewsTest.php:161:    $order = Order::factory()->forCustomer($customer)->paid()->create([
tests/Feature/Storefront/OrderViewsTest.php:163:        'customer_id' => $customer->getKey(),
tests/Feature/Storefront/OrderViewsTest.php:168:        'customer_id' => $otherCustomer->getKey(),
tests/Feature/Storefront/OrderViewsTest.php:176:    $this->actingAs($customer, 'customer');
tests/Feature/Storefront/CartCheckoutUiTest.php:118:test('customer login merges an existing guest cart without creating empty carts', function () {
tests/Feature/Storefront/CartCheckoutUiTest.php:121:    $customer = Customer::withoutGlobalScopes()
tests/Feature/Storefront/CartCheckoutUiTest.php:123:        ->where('email', 'customer@acme.test')
tests/Feature/Storefront/CartCheckoutUiTest.php:125:    $customerCart = app(CartService::class)->create($store, $customer);
tests/Feature/Storefront/CartCheckoutUiTest.php:129:    app(CartService::class)->addLine($customerCart, $variant->getKey(), 1);
tests/Feature/Storefront/CartCheckoutUiTest.php:133:        ->set('email', 'customer@acme.test')
tests/Feature/Storefront/CartCheckoutUiTest.php:138:        ->and($customerCart->refresh()->lines()->withoutGlobalScopes()->where('variant_id', $variant->getKey())->first()?->quantity)->toBe(2)
tests/Feature/Admin/CustomerManagementTest.php:43:function adminCustomerManagementOrder(Store $store, Customer $customer, string $orderNumber, int $totalAmount): Order
tests/Feature/Admin/CustomerManagementTest.php:47:        'customer_id' => $customer->getKey(),
tests/Feature/Admin/CustomerManagementTest.php:53:        'email' => $customer->email,
tests/Feature/Admin/CustomerManagementTest.php:57:test('admin customer routes require authentication and render store scoped customers', function (): void {
tests/Feature/Admin/CustomerManagementTest.php:59:    $customer = adminCustomerManagementCustomer($store, 'jane@example.test', 'Jane Example');
tests/Feature/Admin/CustomerManagementTest.php:60:    adminCustomerManagementOrder($store, $customer, '#8101', 7000);
tests/Feature/Admin/CustomerManagementTest.php:62:        'customer_id' => $customer->getKey(),
tests/Feature/Admin/CustomerManagementTest.php:69:    $this->get('/admin/customers')->assertRedirect('/admin/login');
tests/Feature/Admin/CustomerManagementTest.php:73:        ->get('/admin/customers')
tests/Feature/Admin/CustomerManagementTest.php:81:        ->get('/admin/customers/'.$customer->getKey())
tests/Feature/Admin/CustomerManagementTest.php:89:        ->get('/admin/customers/'.$otherCustomer->getKey())
tests/Feature/Admin/CustomerManagementTest.php:93:test('admin customer index filters by name and email', function (): void {
tests/Feature/Admin/CustomerManagementTest.php:111:test('admin customer detail manages addresses', function (): void {
tests/Feature/Admin/CustomerManagementTest.php:114:    $customer = adminCustomerManagementCustomer($store, 'jane@example.test', 'Jane Example');
tests/Feature/Admin/CustomerManagementTest.php:116:        'customer_id' => $customer->getKey(),
tests/Feature/Admin/CustomerManagementTest.php:121:        ->test(AdminCustomerShow::class, ['customer' => $customer])
tests/Feature/Admin/CustomerManagementTest.php:132:        ->where('customer_id', $customer->getKey())
tests/Feature/Admin/CustomerManagementTest.php:139:        ->test(AdminCustomerShow::class, ['customer' => $customer])
tests/Feature/Admin/CustomerManagementTest.php:154:test('admin customer detail rejects customers from another store', function (): void {
tests/Feature/Admin/CustomerManagementTest.php:162:        ->test(AdminCustomerShow::class, ['customer' => $otherCustomer])
tests/Feature/Storefront/ThemeDataTest.php:104:        ->and(collect($items)->firstWhere('label', 'New Arrivals')['url'])->toBe('/collections/new-arrivals')
app/Policies/CollectionPolicy.php:17:    public function view(User $user, object $collection): bool
app/Policies/CollectionPolicy.php:19:        return $this->isAnyRole($user, $this->storeIdForModel($collection));
app/Policies/CollectionPolicy.php:27:    public function update(User $user, object $collection): bool
app/Policies/CollectionPolicy.php:29:        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($collection));
app/Policies/CollectionPolicy.php:32:    public function delete(User $user, object $collection): bool
app/Policies/CollectionPolicy.php:34:        return $this->isOwnerOrAdmin($user, $this->storeIdForModel($collection));
app/Policies/CustomerPolicy.php:17:    public function view(User $user, object $customer): bool
app/Policies/CustomerPolicy.php:19:        return $this->isAnyRole($user, $this->storeIdForModel($customer));
app/Policies/CustomerPolicy.php:22:    public function update(User $user, object $customer): bool
app/Policies/CustomerPolicy.php:24:        return $this->isOwnerAdminOrStaff($user, $this->storeIdForModel($customer));
app/Services/CheckoutService.php:28:    public function createFromCart(Cart $cart, ?Customer $customer = null): Checkout
app/Services/CheckoutService.php:43:            'customer_id' => $customer?->getKey() ?? $cart->customer_id,
app/Services/DiscountService.php:52:        $minimum = (int) data_get($discount->rules_json, 'min_purchase_amount', data_get($discount->rules_json, 'minimum_purchase', 0));
app/Services/DiscountService.php:54:        if ($minimum > 0 && $subtotal < $minimum) {
app/Services/DiscountService.php:55:            throw InvalidDiscountException::because('discount_min_purchase_not_met', 'Cart does not meet the minimum purchase amount.');
app/Services/DiscountService.php:142:        $productIds = collect(data_get($discount->rules_json, 'applicable_product_ids', []))
app/Services/DiscountService.php:146:        $collectionIds = collect(data_get($discount->rules_json, 'applicable_collection_ids', []))
app/Services/DiscountService.php:151:        if ($productIds->isEmpty() && $collectionIds->isEmpty()) {
app/Services/DiscountService.php:155:        return $lines->filter(function (CartLine $line) use ($productIds, $collectionIds): bool {
app/Services/DiscountService.php:157:                ->with(['product' => fn ($query) => $query->withoutGlobalScopes()->with('collections')])
app/Services/DiscountService.php:168:            return $variant->product->collections
app/Services/DiscountService.php:171:                ->intersect($collectionIds)
app/Livewire/Admin/Collections/Form.php:16:    public ?Collection $collection = null;
app/Livewire/Admin/Collections/Form.php:33:    public function mount(?Collection $collection = null): void
app/Livewire/Admin/Collections/Form.php:35:        if ($collection?->exists) {
app/Livewire/Admin/Collections/Form.php:38:            abort_unless($store instanceof Store && (int) $collection->store_id === $store->getKey(), 404);
app/Livewire/Admin/Collections/Form.php:40:            $this->collection = $collection->load('products');
app/Livewire/Admin/Collections/Form.php:41:            $this->fillFromCollection($this->collection);
app/Livewire/Admin/Collections/Form.php:47:        if ($this->collection === null && $this->handle === '') {
app/Livewire/Admin/Collections/Form.php:80:                Rule::unique('collections', 'handle')
app/Livewire/Admin/Collections/Form.php:82:                    ->ignore($this->collection?->getKey()),
app/Livewire/Admin/Collections/Form.php:97:        $collection = $this->collection instanceof Collection
app/Livewire/Admin/Collections/Form.php:98:            ? tap($this->collection)->update($attributes)
app/Livewire/Admin/Collections/Form.php:101:        $collection->products()->sync(collect($this->assignedProductIds)
app/Livewire/Admin/Collections/Form.php:106:        $this->collection = $collection->refresh()->load('products');
app/Livewire/Admin/Collections/Form.php:107:        $this->fillFromCollection($this->collection);
app/Livewire/Admin/Collections/Form.php:145:        return view('livewire.admin.collections.form', [
app/Livewire/Admin/Collections/Form.php:148:            'isEditing' => $this->collection !== null,
app/Livewire/Admin/Collections/Form.php:150:            'title' => $this->collection ? $this->collection->title : __('Add collection'),
app/Livewire/Admin/Collections/Form.php:154:    private function fillFromCollection(Collection $collection): void
app/Livewire/Admin/Collections/Form.php:156:        $this->title = $collection->title;
app/Livewire/Admin/Collections/Form.php:157:        $this->handle = $collection->handle;
app/Livewire/Admin/Collections/Form.php:158:        $this->descriptionHtml = (string) $collection->description_html;
app/Livewire/Admin/Collections/Form.php:159:        $this->status = $collection->status->value;
app/Livewire/Admin/Collections/Form.php:160:        $this->assignedProductIds = $collection->products->pluck('id')->map(fn (int $id): int => $id)->all();
app/Livewire/Storefront/Collections/Show.php:57:    public function collection(): Collection
app/Livewire/Storefront/Collections/Show.php:67:        $collection = $this->collection();
app/Livewire/Storefront/Collections/Show.php:69:        return $collection->products()
app/Livewire/Storefront/Collections/Show.php:97:        return $this->collection()->products()
app/Livewire/Storefront/Collections/Show.php:108:        return $this->collection()->products()
app/Livewire/Storefront/Collections/Show.php:119:        $collection = $this->collection();
app/Livewire/Storefront/Collections/Show.php:121:        return view('livewire.storefront.collections.show', [
app/Livewire/Storefront/Collections/Show.php:122:            'collection' => $collection,
app/Livewire/Storefront/Collections/Show.php:127:            'title' => $collection->title,
app/Livewire/Admin/Collections/Index.php:36:    public function collections(): LengthAwarePaginator
app/Livewire/Admin/Collections/Index.php:50:        return view('livewire.admin.collections.index', [
app/Livewire/Admin/Collections/Index.php:51:            'collections' => $this->collections(),
app/Livewire/Storefront/Collections/Index.php:11:    public function collections(): SupportCollection
app/Livewire/Storefront/Collections/Index.php:24:        return view('livewire.storefront.collections.index', [
app/Livewire/Storefront/Collections/Index.php:25:            'collections' => $this->collections(),
app/Services/CartService.php:24:    public function create(Store $store, ?Customer $customer = null): Cart
app/Services/CartService.php:28:            'customer_id' => $customer?->getKey(),
app/Services/CartService.php:35:    public function getOrCreateForSession(Store $store, ?Customer $customer = null): Cart
app/Services/CartService.php:39:        if ($customer instanceof Customer) {
app/Services/CartService.php:40:            $customerCart = Cart::withoutGlobalScopes()
app/Services/CartService.php:42:                ->where('customer_id', $customer->getKey())
app/Services/CartService.php:45:                ->first() ?? $this->create($store, $customer);
app/Services/CartService.php:50:                    ->whereNull('customer_id')
app/Services/CartService.php:54:                if ($guestCart instanceof Cart && $guestCart->isNot($customerCart)) {
app/Services/CartService.php:55:                    $customerCart = $this->mergeOnLogin($guestCart, $customerCart);
app/Services/CartService.php:61:            return $customerCart->refresh();
app/Services/CartService.php:67:                ->whereNull('customer_id')
app/Services/CartService.php:82:    public function currentForSession(Store $store, ?Customer $customer = null): ?Cart
app/Services/CartService.php:84:        if ($customer instanceof Customer) {
app/Services/CartService.php:85:            $customerCart = Cart::withoutGlobalScopes()
app/Services/CartService.php:87:                ->where('customer_id', $customer->getKey())
app/Services/CartService.php:92:            if ($customerCart instanceof Cart) {
app/Services/CartService.php:93:                return $customerCart;
app/Services/CartService.php:106:            ->where(function ($query) use ($customer): void {
app/Services/CartService.php:107:                if ($customer instanceof Customer) {
app/Services/CartService.php:109:                        ->whereNull('customer_id')
app/Services/CartService.php:110:                        ->orWhere('customer_id', $customer->getKey());
app/Services/CartService.php:115:                $query->whereNull('customer_id');
app/Services/CartService.php:197:    public function mergeOnLogin(Cart $guest, Cart $customer): Cart
app/Services/CartService.php:199:        return DB::transaction(function () use ($guest, $customer): Cart {
app/Services/CartService.php:201:            $customerCart = $this->freshCart($customer);
app/Services/CartService.php:206:                ->each(function (CartLine $guestLine) use ($customerCart): void {
app/Services/CartService.php:208:                        ->where('cart_id', $customerCart->getKey())
app/Services/CartService.php:221:                    $guestLine->forceFill(['cart_id' => $customerCart->getKey()])->save();
app/Services/CartService.php:225:            $this->incrementVersion($customerCart);
app/Services/CartService.php:227:            return $customerCart->refresh();
app/Http/Controllers/Api/Admin/V1/OrderController.php:29:            ->with('customer')
app/Http/Controllers/Api/Admin/V1/OrderController.php:42:                        ->orWhereHas('customer', fn (Builder $query) => $query->where('name', 'like', $like));
app/Http/Controllers/Api/Admin/V1/OrderController.php:49:        return OrderResource::collection($orders);
app/Http/Controllers/Api/Admin/V1/OrderController.php:75:            'customer',
app/Services/OrderService.php:81:                    'customer_id' => $checkout->customer_id,
app/Livewire/Admin/Orders/Show.php:185:                'customer',
app/Services/ShippingCalculator.php:57:                $specificity = $regions->contains($region) ? 2 : 1;
app/Services/ShippingCalculator.php:59:                if ($specificity > $bestSpecificity) {
app/Services/ShippingCalculator.php:61:                    $bestSpecificity = $specificity;
app/Services/ShippingCalculator.php:97:            $minimum = (int) data_get($range, 'min_g', 0);
app/Services/ShippingCalculator.php:100:            if ($totalWeight >= $minimum && ($maximum === null || $totalWeight <= (int) $maximum)) {
app/Services/ShippingCalculator.php:115:            $minimum = (int) data_get($range, 'min_amount', 0);
app/Services/ShippingCalculator.php:118:            if ($subtotal >= $minimum && ($maximum === null || $subtotal <= (int) $maximum)) {
app/Livewire/Admin/Products/Form.php:43:    public array $collectionIds = [];
app/Livewire/Admin/Products/Form.php:62:            $this->product = $product->load(['options.values', 'variants.inventoryItem', 'variants.optionValues.option', 'collections']);
app/Livewire/Admin/Products/Form.php:154:            $product->collections()->sync($this->collectionIds);
app/Livewire/Admin/Products/Form.php:159:        $this->product = $product->load(['options.values', 'variants.inventoryItem', 'variants.optionValues.option', 'collections']);
app/Livewire/Admin/Products/Form.php:196:        $this->collectionIds = $product->collections->pluck('id')->map(fn (int $id): int => $id)->all();
app/Livewire/Storefront/Account/Orders/Show.php:23:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Account/Orders/Show.php:25:        abort_unless($store instanceof Store && $customer instanceof Customer, 404);
app/Livewire/Storefront/Account/Orders/Show.php:29:            ->where('customer_id', $customer->getKey())
app/Livewire/Storefront/Account/Orders/Show.php:53:            ->where('customer_id', Auth::guard('customer')->id())
app/Livewire/Admin/Orders/Index.php:82:            ->with('customer')
app/Livewire/Admin/Orders/Index.php:92:                        ->orWhereHas('customer', fn (Builder $query) => $query->where('name', 'like', $search));
app/Livewire/Storefront/Account/Orders/Index.php:41:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Account/Orders/Index.php:43:        abort_unless($customer instanceof Customer, 403);
app/Livewire/Storefront/Account/Orders/Index.php:47:            ->where('customer_id', $customer->getKey())
app/Livewire/Admin/Customers/Show.php:23:    public int $customerId;
app/Livewire/Admin/Customers/Show.php:43:    public function mount(Customer $customer): void
app/Livewire/Admin/Customers/Show.php:49:        $customer = Customer::withoutGlobalScopes()
app/Livewire/Admin/Customers/Show.php:51:            ->whereKey($customer->getKey())
app/Livewire/Admin/Customers/Show.php:54:        abort_unless($customer instanceof Customer, 404);
app/Livewire/Admin/Customers/Show.php:57:        $this->customerId = $customer->getKey();
app/Livewire/Admin/Customers/Show.php:91:            : new CustomerAddress(['customer_id' => $this->customerId]);
app/Livewire/Admin/Customers/Show.php:96:            'is_default' => $address->exists ? $address->is_default : ! $this->customer()->addresses()->exists(),
app/Livewire/Admin/Customers/Show.php:124:                ->where('customer_id', $this->customerId)
app/Livewire/Admin/Customers/Show.php:137:            ->where('customer_id', $this->customerId)
app/Livewire/Admin/Customers/Show.php:145:        $customer = $this->customer();
app/Livewire/Admin/Customers/Show.php:147:        return view('livewire.admin.customers.show', [
app/Livewire/Admin/Customers/Show.php:148:            'customer' => $customer,
app/Livewire/Admin/Customers/Show.php:151:            'title' => $customer->name ?: $customer->email,
app/Livewire/Admin/Customers/Show.php:155:    private function customer(): Customer
app/Livewire/Admin/Customers/Show.php:160:            ->whereKey($this->customerId)
app/Livewire/Admin/Customers/Show.php:167:            ->where('customer_id', $this->customerId)
app/Livewire/Admin/Customers/Show.php:175:            ->where('customer_id', $this->customerId)
app/Livewire/Storefront/Account/Auth/Register.php:46:                Rule::unique('customers', 'email')->where('store_id', $store->getKey()),
app/Livewire/Storefront/Account/Auth/Register.php:52:        $customer = Customer::withoutGlobalScopes()->create([
app/Livewire/Storefront/Account/Auth/Register.php:60:        Auth::guard('customer')->login($customer);
app/Livewire/Admin/Customers/Index.php:39:    public function customers(): LengthAwarePaginator
app/Livewire/Admin/Customers/Index.php:60:        return view('livewire.admin.customers.index', [
app/Livewire/Admin/Customers/Index.php:61:            'customers' => $this->customers(),
app/Services/NavigationService.php:59:            NavigationItemType::Collection => $this->collectionUrl($item),
app/Services/NavigationService.php:78:    private function collectionUrl(NavigationItem $item): string
app/Services/NavigationService.php:80:        $collection = ProductCollection::withoutGlobalScopes()
app/Services/NavigationService.php:84:        return $collection ? route('collections.show', $collection->handle, false) : '#';
app/Livewire/Storefront/Checkout/Confirmation.php:33:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Checkout/Confirmation.php:35:        $isCustomerOrder = $customer instanceof Customer && $order->customer_id === $customer->getKey();
app/Livewire/Storefront/Checkout/Confirmation.php:55:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Checkout/Confirmation.php:58:        abort_if(! $customer instanceof Customer && $sessionOrderId === null, 404);
app/Livewire/Storefront/Checkout/Confirmation.php:64:            ->where(function ($query) use ($customer, $sessionOrderId): void {
app/Livewire/Storefront/Checkout/Confirmation.php:65:                if ($customer instanceof Customer) {
app/Livewire/Storefront/Checkout/Confirmation.php:66:                    $query->orWhere('customer_id', $customer->getKey());
app/Livewire/Storefront/Products/Show.php:75:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Products/Show.php:76:        $customer = $customer instanceof Customer ? $customer : null;
app/Livewire/Storefront/Products/Show.php:79:            app(CartService::class)->getOrCreateForSession($store, $customer),
app/Livewire/Storefront/Products/Show.php:109:            ->with(['options.values', 'variants.inventoryItem', 'variants.optionValues.option', 'collections'])
app/Services/ThemeSettingsService.php:71:                    'primary_url' => '/collections/new-arrivals',
app/Services/ThemeSettingsService.php:72:                    'secondary_label' => 'View collections',
app/Services/ThemeSettingsService.php:73:                    'secondary_url' => '/collections',
app/Services/ThemeSettingsService.php:76:                'featured_collection_limit' => 4,
app/Livewire/Storefront/Account/Auth/Login.php:40:        $key = 'customer-login:'.request()->ip();
app/Livewire/Storefront/Account/Auth/Login.php:52:        if (! Auth::guard('customer')->attempt([
app/Livewire/Storefront/Account/Auth/Login.php:69:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Account/Auth/Login.php:71:        if ($customer instanceof Customer && session()->has('cart_id')) {
app/Livewire/Storefront/Account/Auth/Login.php:72:            app(CartService::class)->getOrCreateForSession(Store::query()->findOrFail($this->storeId), $customer);
app/Models/CustomerAddress.php:20:        'customer_id',
app/Models/CustomerAddress.php:29:    public function customer(): BelongsTo
app/Livewire/Storefront/Home.php:41:            ->limit((int) data_get($this->themeSettings(), 'home.featured_collection_limit', 4))
app/Livewire/Storefront/Checkout/Show.php:82:        $this->email = $this->customer()?->email ?? '';
app/Livewire/Storefront/Checkout/Show.php:271:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/Checkout/Show.php:294:            $checkout = app(CheckoutService::class)->createFromCart($cart, $this->customer());
app/Livewire/Storefront/Checkout/Show.php:390:    private function customer(): ?Customer
app/Livewire/Storefront/Checkout/Show.php:392:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Checkout/Show.php:394:        return $customer instanceof Customer ? $customer : null;
app/Livewire/Storefront/Cart/Show.php:158:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/Cart/Show.php:286:    private function customer(): ?Customer
app/Livewire/Storefront/Cart/Show.php:288:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/Cart/Show.php:290:        return $customer instanceof Customer ? $customer : null;
app/Livewire/Storefront/CartDrawer.php:90:        $cart = app(CartService::class)->currentForSession($this->store(), $this->customer());
app/Livewire/Storefront/CartDrawer.php:126:    private function customer(): ?Customer
app/Livewire/Storefront/CartDrawer.php:128:        $customer = Auth::guard('customer')->user();
app/Livewire/Storefront/CartDrawer.php:130:        return $customer instanceof Customer ? $customer : null;
app/Models/Discount.php:31:        'rules_json',
app/Models/Discount.php:42:        'rules_json' => '{}',
app/Models/Discount.php:67:            'rules_json' => 'array',
app/Models/Order.php:26:        'customer_id',
app/Models/Order.php:78:    public function customer(): BelongsTo
app/Models/Cart.php:22:        'customer_id',
app/Models/Cart.php:48:    public function customer(): BelongsTo
app/Models/Product.php:76:    public function collections(): BelongsToMany
app/Models/Product.php:78:        return $this->belongsToMany(Collection::class, 'collection_products')
app/Models/Checkout.php:22:        'customer_id',
app/Models/Checkout.php:61:    public function customer(): BelongsTo
app/Models/Collection.php:51:        return $this->belongsToMany(Product::class, 'collection_products')
app/Http/Resources/Admin/V1/OrderResource.php:22:            'customer' => $this->whenLoaded('customer', fn () => $this->customer ? [
app/Http/Resources/Admin/V1/OrderResource.php:23:                'id' => $this->customer->id,
app/Http/Resources/Admin/V1/OrderResource.php:24:                'name' => $this->customer->name,
app/Http/Resources/Admin/V1/OrderResource.php:25:                'email' => $this->customer->email,
app/Http/Resources/Admin/V1/OrderResource.php:57:            'refunds' => RefundResource::collection($this->whenLoaded('refunds')),
app/Http/Resources/Admin/V1/OrderResource.php:58:            'fulfillments' => FulfillmentResource::collection($this->whenLoaded('fulfillments')),
app/Enums/NavigationItemType.php:9:    case Collection = 'collection';
app/Http/Resources/Storefront/V1/CartResource.php:22:            'customer_id' => $this->customer_id,
app/Http/Resources/Storefront/V1/CartResource.php:33:            'lines' => CartLineResource::collection($lines),
app/Http/Resources/Storefront/V1/CheckoutResource.php:21:            'customer_id' => $this->customer_id,
app/Http/Resources/Storefront/V1/CheckoutResource.php:31:            'available_shipping_rates' => ShippingRateResource::collection($this->whenLoaded('availableRates')),


cmd: rg -n "function save|redirect" app/Livewire/Admin/Collections/Form.php app/Livewire/Admin/Products/Form.php


command: rg -n "function save|redirect" app/Livewire/Admin/Collections/Form.php app/Livewire/Admin/Products/Form.php

type: search

cmd: rg -n 'function save|redirect' app/Livewire/Admin/Collections/Form.php app/Livewire/Admin/Products/Form.php

query: function save|redirect

aggregated_output:
app/Livewire/Admin/Collections/Form.php:69:    public function save(): void
app/Livewire/Admin/Products/Form.php:100:    public function save(): void
app/Livewire/Admin/Products/Form.php:173:        $this->redirectRoute('admin.products.index', navigate: true);


output:
Chunk ID: 1537b2
Wall time: 0.0000 seconds
Process exited with code 0
Original token count: 66
Output:
app/Livewire/Admin/Collections/Form.php:69:    public function save(): void
app/Livewire/Admin/Products/Form.php:100:    public function save(): void
app/Livewire/Admin/Products/Form.php:173:        $this->redirectRoute('admin.products.index', navigate: true);


cmd: sed -n '60,115p' app/Livewire/Admin/Collections/Form.php && sed -n '90,180p' app/Livewire/Admin/Products/Form.php