### Default Configuration Example Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md The configuration file allows specifying directories for searchable models using glob patterns. ```php return [ 'model_directories' => [ app_path('Models'), // base_path('Modules/*/Models'), ], ]; ``` -------------------------------- ### Install Laravel Scout Bulk Actions Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Install the package using Composer. Ensure you have PHP 8.2+. ```bash composer require mozex/laravel-scout-bulk-actions ``` -------------------------------- ### Install Laravel Scout Bulk Actions Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Use Composer to install the package and publish the configuration file. ```bash # Install the package composer require mozex/laravel-scout-bulk-actions # The package auto-registers via Laravel's package discovery # No manual service provider registration required # Publish the configuration file (optional) php artisan vendor:publish --tag="scout-bulk-actions-config" ``` -------------------------------- ### Publish Configuration File Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Publish the configuration file to customize model directories. The default scans app/Models. ```bash php artisan vendor:publish --tag="scout-bulk-actions-config" ``` -------------------------------- ### Import All Searchable Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Use this command to import all discovered searchable models into the search index. Control batch size with --chunk. ```bash php artisan scout:import-all ``` ```bash php artisan scout:import-all --chunk=200 ``` -------------------------------- ### Import All Searchable Models Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Execute bulk imports for all discovered models with optional chunking and force flags. ```bash # Import all searchable models with default chunk size php artisan scout:import-all # Import with custom chunk size (records per batch) php artisan scout:import-all --chunk=200 # Skip production confirmation prompt (for CI/CD pipelines) php artisan scout:import-all --force # Combine options php artisan scout:import-all --chunk=500 --force # Expected output: # Importing records... # 5/5 [============================] 100% ``` -------------------------------- ### Run All Checks (Composer) Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/CLAUDE.md Execute all checks including formatting, static analysis, and tests using Composer. ```bash composer test ``` -------------------------------- ### Configuration: Model Discovery Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Details on how to configure model discovery directories and the process involved. ```APIDOC ## Configuration ### Description The package finds models by scanning directories listed in `config/scout-bulk-actions.php`. Publish the config file to customize these directories. ### Publish Command ```bash php artisan vendor:publish --tag=scout-bulk-actions-config ``` ### Configuration File Example (`config/scout-bulk-actions.php`) ```php return [ 'model_directories' => [ app_path('Models'), // base_path('Modules/*/Models'), ], ]; ``` ### How Discovery Works For each `.php` file in the configured directories, the package performs the following checks: 1. Converts the file path to a fully qualified class name. 2. Checks if the class exists and can be resolved by the autoloader. 3. Verifies the class is not abstract using `ReflectionClass`. 4. Confirms the class extends `Illuminate\Database\Eloquent\Model`. 5. Confirms the class uses the `Laravel\Scout\Searchable` trait directly. All five checks must pass for a model to be discovered. Files failing any check are silently skipped. ### Direct Trait Use Note that the `Searchable` trait must be applied directly to the model class. If a parent model uses the trait and child models extend it, the child models will not be discovered because `class_uses()` only checks the class's own traits, not inherited ones. ``` -------------------------------- ### scout:queue-import-all Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Dispatches queued jobs to import all searchable models. Ideal for large datasets. ```APIDOC ## POST /artisan scout:queue-import-all ### Description Dispatches queued jobs to import all searchable models. Use this for large datasets. ### Method POST ### Endpoint /artisan scout:queue-import-all ### Parameters #### Query Parameters - **--chunk** (integer) - Optional - Records per queued job. Falls back to `scout.chunk.searchable` config if omitted. - **-c** (integer) - Optional - Alias for --chunk. - **--queue** (string) - Optional - Target queue name. Falls back to `scout.queue.queue` config if omitted. - **--force** (boolean) - Optional - Skips the production confirmation prompt. ### Request Example ```bash php artisan scout:queue-import-all php artisan scout:queue-import-all --chunk=500 --queue=scout ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating that queued import jobs have been dispatched. #### Response Example ```json { "message": "Queued import jobs have been dispatched for all searchable models." } ``` ``` -------------------------------- ### Import All Scout Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Use to discover all searchable models and import them into the search index. Options include specifying the chunk size for batches or forcing the operation without a confirmation prompt. ```bash php artisan scout:import-all ``` ```bash php artisan scout:import-all --chunk=500 ``` ```bash php artisan scout:import-all --force ``` -------------------------------- ### Queue Import All Models Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Dispatch asynchronous jobs to import models, suitable for large datasets. ```bash # Queue import all models with default settings php artisan scout:queue-import-all # Set custom chunk size per job php artisan scout:queue-import-all --chunk=500 # Specify which queue to dispatch jobs to php artisan scout:queue-import-all --queue=indexing # Combine all options for production deployment php artisan scout:queue-import-all --chunk=1000 --queue=search-indexing --force # Expected output: # Queuing records for import... # 5/5 [============================] 100% # Monitor queued jobs php artisan queue:work --queue=indexing ``` -------------------------------- ### scout:import-all Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Discovers all searchable models and imports each one into the search index. ```APIDOC ## POST /artisan scout:import-all ### Description Discovers all searchable models and imports each one into the search index. ### Method POST ### Endpoint /artisan scout:import-all ### Parameters #### Query Parameters - **--chunk** (integer) - Optional - Records per batch. Falls back to `scout.chunk.searchable` config if omitted. - **-c** (integer) - Optional - Alias for --chunk. - **--force** (boolean) - Optional - Skips the production confirmation prompt. ### Request Example ```bash php artisan scout:import-all php artisan scout:import-all --chunk=500 php artisan scout:import-all --force ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the import process has started or completed. #### Response Example ```json { "message": "All searchable models have been imported." } ``` ``` -------------------------------- ### Configure Model Directories for Scout Bulk Actions Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Configure the package to scan multiple directories using glob patterns for modular or domain-driven architectures. This allows the bulk commands to discover models located in various custom paths. ```php [ // Standard Laravel models directory app_path('Models'), // Domain-driven design structure app_path('Domain/*/Models'), // Modular monolith with Modules directory base_path('Modules/*/Models'), // Package models base_path('packages/*/src/Models'), // Multiple specific paths app_path('Models/Blog'), app_path('Models/Shop'), app_path('Models/User'), ], ]; // Example directory structure that would be scanned: // app/ // Models/ // User.php <- Scanned // Post.php <- Scanned // Domain/ // Blog/ // Models/ // Article.php <- Scanned with glob pattern // Shop/ // Models/ // Product.php <- Scanned with glob pattern // Modules/ // Inventory/ // Models/ // Stock.php <- Scanned with glob pattern ``` -------------------------------- ### Run Single Test File (Pest) Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/CLAUDE.md Execute a single test file using the Pest testing framework. ```bash ./vendor/bin/pest tests/Commands/ImportAllCommandTest.php ``` -------------------------------- ### Configure Searchable Model Directories Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Define the paths where the package should scan for models using the Searchable trait. ```php [ app_path('Models'), // Scan all module Model directories using glob pattern // base_path('Modules/*/Models'), ], ]; // After changing config in production, clear the cache: // php artisan config:clear ``` -------------------------------- ### Configure Model Discovery Directories Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md This PHP configuration array defines the directories where the package scans for searchable Eloquent models. Glob patterns can be used to include models from modular applications. ```php // config/scout-bulk-actions.php return [ 'model_directories' => [ app_path('Models'), // base_path('Modules/*/Models'), ], ]; ``` -------------------------------- ### Queue Import for All Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Dispatches queued jobs to import all models, suitable for large datasets. Options include --chunk and --queue. ```bash php artisan scout:queue-import-all ``` ```bash php artisan scout:queue-import-all --chunk=500 ``` ```bash php artisan scout:queue-import-all --queue=indexing ``` -------------------------------- ### Publish Scout Bulk Actions Config Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Use this command to publish the configuration file for Scout Bulk Actions, allowing customization of model discovery directories. ```bash php artisan vendor:publish --tag=scout-bulk-actions-config ``` -------------------------------- ### Force Production Commands Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md To skip confirmation prompts in production environments for automated scripts or CI pipelines, use the `--force` option with the relevant commands. ```bash php artisan scout:import-all --force ``` ```bash php artisan scout:flush-all --force ``` ```bash php artisan scout:queue-import-all --force ``` ```bash php artisan scout:refresh --force ``` -------------------------------- ### Queue Import All Scout Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Use for large datasets to import all searchable models via queued jobs. You can specify the chunk size for each job and the target queue name. The `--force` option bypasses the production confirmation. ```bash php artisan scout:queue-import-all ``` ```bash php artisan scout:queue-import-all --chunk=500 --queue=scout ``` -------------------------------- ### Refresh Search Index Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Use this command to flush and then import all search indexes in one step. This is useful when a clean re-index is required. It can target a single model or all models. ```bash php artisan scout:refresh ``` ```bash php artisan scout:refresh "App\Models\Post" ``` -------------------------------- ### Refresh Search Indexes Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Perform a flush followed by an import for all or specific models. ```bash # Refresh all searchable models (flush-all + import-all) php artisan scout:refresh # Refresh a specific model only php artisan scout:refresh "App\Models\Post" # Refresh with custom chunk size php artisan scout:refresh --chunk=300 # Refresh single model with options php artisan scout:refresh "App\Models\User" --chunk=500 --force # Refresh all in production without prompt php artisan scout:refresh --force # Expected output for single model: # Flushing [App\Models\Post]... # Importing [App\Models\Post]... ``` -------------------------------- ### Run Single Test by Name (Pest) Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/CLAUDE.md Execute a specific test by its name or filter using the Pest testing framework. ```bash ./vendor/bin/pest --filter="test name here" ``` -------------------------------- ### Individual Checks (Composer) Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/CLAUDE.md Run specific checks like code formatting, static analysis, or unit tests using Composer. ```bash composer lint # Fix code formatting (Pint) composer test:lint # Check code formatting without fixing composer test:types # PHPStan static analysis (level 6) composer test:unit # Run Pest tests ``` -------------------------------- ### scout:refresh Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Performs a full re-index by flushing and then importing all searchable models. ```APIDOC ## POST /artisan scout:refresh ### Description Flushes then imports for a clean re-index. Works for one model or all of them. ### Method POST ### Endpoint /artisan scout:refresh ### Parameters #### Path Parameters - **model** (string) - Optional - Fully qualified class name of the model to refresh. If omitted, it refreshes all models. #### Query Parameters - **--chunk** (integer) - Optional - Passed through to the import step. Records per batch. - **-c** (integer) - Optional - Alias for --chunk. - **--force** (boolean) - Optional - Skips the production confirmation prompt. When refreshing all models, this is passed to sub-commands automatically. ### Request Example ```bash # All models php artisan scout:refresh # Single model php artisan scout:refresh "App\Models\Post" # With chunk size php artisan scout:refresh --chunk=500 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the refresh process has completed. #### Response Example ```json { "message": "All searchable models have been refreshed." } ``` ``` -------------------------------- ### Refresh Scout Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Performs a clean re-index by flushing then importing models. This command can target all models or a single specified model. Options include setting a chunk size for the import step and forcing the operation. ```bash # All models php artisan scout:refresh ``` ```bash # Single model php artisan scout:refresh "App\Models\Post" ``` ```bash # With chunk size php artisan scout:refresh --chunk=500 ``` -------------------------------- ### Flush All Scout Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Use to remove all records from the search index for every discovered model. The `--force` option can be used to skip the production confirmation prompt. ```bash php artisan scout:flush-all ``` ```bash php artisan scout:flush-all --force ``` -------------------------------- ### Define Searchable Model with Scout Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Models must use Laravel Scout's Searchable trait and reside in a configured directory to be auto-discovered by the bulk commands. Implement `toSearchableArray` to define the data to be indexed and `searchableAs` to specify the index name. ```php */ public function toSearchableArray(): array { return [ 'id' => $this->id, 'title' => $this->title, 'content' => $this->content, 'author' => $this->author->name, 'published_at' => $this->published_at?->timestamp, ]; } /** * Get the name of the index associated with the model. */ public function searchableAs(): string { return 'posts_index'; } } ``` -------------------------------- ### scout:flush-all Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/resources/boost/skills/scout-bulk-actions/SKILL.md Removes all records from the search index for every discovered model. ```APIDOC ## POST /artisan scout:flush-all ### Description Removes all records from the search index for every discovered model. ### Method POST ### Endpoint /artisan scout:flush-all ### Parameters #### Query Parameters - **--force** (boolean) - Optional - Skips the production confirmation prompt. ### Request Example ```bash php artisan scout:flush-all php artisan scout:flush-all --force ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the flush process has completed. #### Response Example ```json { "message": "All records have been flushed from the search index." } ``` ``` -------------------------------- ### Flush All Search Indexes Source: https://context7.com/mozex/laravel-scout-bulk-actions/llms.txt Remove all indexed records for every discovered searchable model. ```bash # Flush all search indexes php artisan scout:flush-all # Skip production confirmation prompt php artisan scout:flush-all --force # Expected output: # Flushing records... # 5/5 [============================] 100% ``` -------------------------------- ### Flush All Searchable Models Source: https://github.com/mozex/laravel-scout-bulk-actions/blob/main/README.md Removes all records from the search index for every discovered searchable model. ```bash php artisan scout:flush-all ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.