### Livewire Lifecycle Hook Examples Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Illustrates the usage of Livewire lifecycle hooks for initialization and handling reactive side effects. The `mount()` hook is used for initial component setup, while `updatedFoo()` is triggered when a property named `foo` changes. ```php public function mount(User $user) { $this->user = $user; } public function updatedSearch() { $this->resetPage(); } ``` -------------------------------- ### Install Dependencies (Composer & PNPM) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Installs project dependencies using Composer for PHP and PNPM for Node.js. This is a crucial step for setting up the development environment. ```bash composer install && pnpm install ``` -------------------------------- ### Error Handling Examples (Bash) Source: https://context7.com/muetze42/hellofresh-database/llms.txt Provides examples of common API error responses, including their HTTP status codes and JSON payloads. Covers '401 Unauthorized' for authentication issues, '404 Not Found' for invalid resources, '422 Unprocessable Entity' for validation errors, and '429 Too Many Requests' for rate limiting. ```bash # 401 Unauthorized - Missing or invalid token { "message": "Unauthenticated." } # 404 Not Found - Invalid locale/country or resource not found { "message": "Not Found" } # 422 Unprocessable Entity - Validation errors { "message": "The difficulty field must be a valid difficulty level.", "errors": { "difficulty": ["The difficulty field must be a valid difficulty level."] } } # 429 Too Many Requests - Rate limit exceeded { "message": "Too Many Attempts." } ``` -------------------------------- ### Flex Gap Spacing Example Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Example of using Tailwind CSS `gap` utilities for spacing between flex items. This is the preferred method over using margins for consistent spacing. ```html
Superior
Michigan
Erie
``` -------------------------------- ### List Recipe Labels (JSON Response Example) Source: https://context7.com/muetze42/hellofresh-database/llms.txt An example JSON response for the 'List Recipe Labels' endpoint. It contains a 'data' array with label objects, each having an 'id', 'name', 'created_at', and 'updated_at' field. The 'meta' object provides pagination details. ```json { "data": [ {"id": 1, "name": "Vegetarian", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 2, "name": "Vegan", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 3, "name": "Family Friendly", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"} ], "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 8, "total": 8 } } ``` -------------------------------- ### Livewire Keyed Loop Example Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Demonstrates the use of `wire:key` within a loop in Livewire components. Adding `wire:key` is crucial for Livewire to efficiently track and update DOM elements during list rendering. ```blade @foreach ($items as $item)
{{ $item->name }}
@endforeach ``` -------------------------------- ### Install Inter Fonts on Ubuntu Linux Source: https://github.com/muetze42/hellofresh-database/blob/main/resources/fonts/inter/help.txt This snippet demonstrates how to install Inter font files on Ubuntu Linux by creating a .fonts directory and copying the font files into it. It also notes that applications and the window server session may need to be restarted. ```bash mkdir -p ~/.fonts cp Inter.ttc *.ttf ~/.fonts/ ``` -------------------------------- ### Get Single Recipe - Bash Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves detailed information for a specific recipe, including its ingredients, allergens, cuisines, and required utensils. This is done by sending a GET request to the /{country-locale}/recipes/{recipeId} endpoint. ```bash # Get recipe details curl -X GET "https://api.hfresh.info/de-DE/recipes/12345" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` -------------------------------- ### List Recipe Labels (Bash) Source: https://context7.com/muetze42/hellofresh-database/llms.txt Fetches all available recipe labels (dietary categories) for a specified country using a GET request. Requires an API token for authentication and specifies JSON as the accepted response format. The response includes a list of labels with their IDs and names, along with pagination metadata. ```bash # Get all labels for Great Britain curl -X GET "https://api.hfresh.info/en-GB/labels" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` -------------------------------- ### List Allergens (JSON Response Example) Source: https://context7.com/muetze42/hellofresh-database/llms.txt An example JSON response for the 'List Allergens' endpoint. It includes a 'data' array containing allergen objects, each with an 'id', 'name', 'created_at', and 'updated_at' field. The 'meta' object provides pagination details. ```json { "data": [ {"id": 1, "name": "Gluten", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 2, "name": "Oeufs", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 3, "name": "Lait", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 4, "name": "Fruits à coque", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"} ], "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 14, "total": 14 } } ``` -------------------------------- ### Get Single Recipe Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves detailed information about a specific recipe, including its allergens, ingredients, cuisines, and utensils. ```APIDOC ## GET /{country}-{locale}/recipes/{id} ### Description Returns detailed information about a specific recipe including allergens, ingredients, cuisines, and utensils. ### Method GET ### Endpoint `/{country}-{locale}/recipes/{id}` ### Parameters #### Path Parameters - **country** (string) - Required - The country code (e.g., "de", "gb"). - **locale** (string) - Required - The locale code (e.g., "DE", "EN"). - **id** (integer) - Required - The unique identifier of the recipe. #### Query Parameters - **Authorization** (string) - Required - Bearer token for authentication. - **Accept** (string) - Optional - `application/json` ### Request Example ```bash curl -X GET "https://api.hfresh.info/de-DE/recipes/12345" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier for the recipe. - **canonical_id** (integer) - The canonical ID of the recipe. - **variant** (boolean) - Indicates if this is a recipe variant. - **url** (string) - The URL to the recipe on the HelloFresh website. - **name** (string) - The name of the recipe. - **headline** (string) - A short headline for the recipe. - **description** (string) - A detailed description of the recipe. - **difficulty** (integer) - The difficulty level (1: Easy, 2: Medium, 3: Hard). - **prep_time** (integer) - The preparation time in minutes. - **total_time** (integer) - The total time in minutes. - **pdf_url** (string) - The URL to the PDF recipe card. - **has_pdf** (boolean) - Indicates if a PDF card is available. - **nutrition** (object) - Nutritional information. - **calories** (integer) - Calories per serving. - **protein** (integer) - Protein per serving (grams). - **carbohydrates** (integer) - Carbohydrates per serving (grams). - **fat** (integer) - Fat per serving (grams). - **label** (object) - The primary label for the recipe. - **id** (integer) - The label ID. - **name** (string) - The name of the label. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. - **tags** (array) - An array of tag objects associated with the recipe. - **id** (integer) - The tag ID. - **name** (string) - The name of the tag. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. - **allergens** (array) - An array of allergen objects associated with the recipe. - **id** (integer) - The allergen ID. - **name** (string) - The name of the allergen. - **ingredients** (array) - An array of ingredient objects for the recipe. - **id** (integer) - The ingredient ID. - **name** (string) - The name of the ingredient. - **pivot** (object) - Pivot data for the ingredient in the recipe. - **quantity** (string) - The quantity of the ingredient. - **unit** (string) - The unit of measurement for the ingredient. - **preparation** (string) - Any specific preparation instructions for the ingredient. - **cuisines** (array) - An array of cuisine objects associated with the recipe. - **id** (integer) - The cuisine ID. - **name** (string) - The name of the cuisine. - **utensils** (array) - An array of utensil objects required for the recipe. - **id** (integer) - The utensil ID. - **name** (string) - The name of the utensil. - **created_at** (string) - Timestamp of when the recipe was created. - **updated_at** (string) - Timestamp of when the recipe was last updated. #### Response Example ```json { "id": 12345, "canonical_id": 12340, "variant": false, "url": "https://hfresh.info/de-DE/recipes/cremige-pasta-12345", "name": "Cremige Pasta", "headline": "Mit frischem Basilikum", "description": "Ein schnelles und leckeres Pasta-Gericht...", "difficulty": 1, "prep_time": 15, "total_time": 30, "pdf_url": "https://hellofresh.com/recipe-cards/12345.pdf", "has_pdf": true, "nutrition": { "calories": 650, "protein": 25, "carbohydrates": 80, "fat": 22 }, "label": { "id": 5, "name": "Vegetarisch", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z" }, "tags": [ { "id": 12, "name": "Schnell", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z" } ], "allergens": [ { "id": 1, "name": "Gluten" } ], "ingredients": [ { "id": 101, "name": "Spaghetti", "pivot": { "quantity": "250g", "unit": "g", "preparation": "" } } ], "cuisines": [ { "id": 3, "name": "Italienisch" } ], "utensils": [ { "id": 7, "name": "Kochtopf" } ], "created_at": "2024-01-15T10:30:00.000000Z", "updated_at": "2024-01-20T14:22:00.000000Z" } ``` ``` -------------------------------- ### List Allergens (Bash) Source: https://context7.com/muetze42/hellofresh-database/llms.txt Fetches all tracked allergens for recipes in a specific country using a GET request. It requires an API token for authentication and accepts JSON responses. The output includes a list of allergens with their IDs and names, along with pagination metadata. ```bash # Get allergens for France curl -X GET "https://api.hfresh.info/fr-FR/allergens" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` -------------------------------- ### List Available Countries - Bash Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves a paginated list of all active HelloFresh countries, including recipe and ingredient counts. This endpoint does not require localization parameters and uses a GET request to the /countries endpoint. ```bash # Get all available countries curl -X GET "https://api.hfresh.info/countries" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` -------------------------------- ### Flux UI Button Component Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Example of using a Flux UI button component with a primary variant. Flux UI is a component library for Livewire applications, built with Tailwind CSS. ```blade ``` -------------------------------- ### Test Livewire Component Existence on Page Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md This snippet shows how to test if a specific Livewire component is rendered on a given page. It makes a GET request to a URL and asserts the presence of the Livewire component class in the response. ```php $this->get('/posts/create') ->assertSeeLivewire(CreatePost::class); ``` -------------------------------- ### Include Inter Fonts via HTML Link Tags Source: https://github.com/muetze42/hellofresh-database/blob/main/resources/fonts/inter/help.txt This snippet illustrates how to link Inter font files and their corresponding CSS from a web server or a CDN into an HTML document's head section. It includes preconnect directives for performance optimization. ```html ``` ```html ``` -------------------------------- ### Configure Inter Fonts in Web Content CSS Source: https://github.com/muetze42/hellofresh-database/blob/main/resources/fonts/inter/help.txt This code shows how to integrate the Inter font into web content using CSS. It includes rules for both variable and static font declarations, ensuring proper fallback and optimal rendering. ```css :root { font-family: 'Inter', sans-serif; } @supports (font-variation-settings: normal) { :root { font-family: 'Inter var', sans-serif; } } ``` -------------------------------- ### Resolve Vite Manifest Error Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md If you encounter an 'Illuminate\Foundation\ViteException: Unable to locate file in Vite manifest' error, you can resolve it by running `pnpm run build` to build the assets or by asking the user to run `pnpm run dev` or `composer run dev` to start the development server. ```bash pnpm run build ``` ```bash pnpm run dev ``` ```bash composer run dev ``` -------------------------------- ### Run All Tests Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Command to execute the entire test suite in compact mode. This is useful for ensuring overall application stability. ```bash php artisan test --compact ``` -------------------------------- ### Run All Tests in a File Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Command to run all tests within a specific file. This is helpful for focusing on a particular set of tests. ```bash php artisan test --compact tests/Feature/ExampleTest.php ``` -------------------------------- ### Run Database Migrations (Artisan) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Applies database migrations using the Artisan command. This ensures the database schema is up-to-date with the project's requirements. ```bash php artisan migrate ``` -------------------------------- ### Test Livewire Component State and Actions Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md This snippet demonstrates how to test a Livewire component's state and actions using the Livewire testing facade. It asserts initial state, triggers an action, and verifies the resulting state and rendered output. ```php Livewire::test(Counter::class) ->assertSet('count', 0) ->call('increment') ->assertSet('count', 1) ->assertSee(1) ->assertStatus(200); ``` -------------------------------- ### Create Feature or Unit Test using Artisan Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Use the `php artisan make:test` command to generate feature or unit tests. Feature tests are recommended for most scenarios. This command helps in scaffolding test files efficiently. ```bash php artisan make:test [options] {name} php artisan make:test --unit [options] {name} ``` -------------------------------- ### PHP Constructor Property Promotion Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Utilizes PHP 8's constructor property promotion for concise constructor definitions. This reduces boilerplate code by allowing properties to be declared directly in the constructor signature. ```php public function __construct(public GitHub $github) { } ``` -------------------------------- ### PHP Explicit Return Types and Method Parameters Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Demonstrates the use of explicit return type declarations for methods and specific PHP type hints for method parameters. This improves code readability and maintainability by clearly defining expected data types. ```php protected function isAccessible(User $user, ?string $path = null): bool { ... } ``` -------------------------------- ### Create Livewire Component using Artisan Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Command to create a new Livewire component using the Artisan CLI. This command scaffolds the necessary files for a new Livewire component, such as `CreatePost` in the `Posts` directory. ```bash php artisan make:livewire [Posts\CreatePost] ``` -------------------------------- ### Run Tests (Composer) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Executes project tests using Composer. This is part of the quality assurance process to ensure new features and fixes work as expected. ```bash composer test ``` -------------------------------- ### Format Code with Laravel Pint Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Instructions for using Laravel Pint to format code. It specifies the command to run for dirty checks and the command to fix formatting issues. ```bash vendor/bin/pint --dirty ``` ```bash vendor/bin/pint ``` -------------------------------- ### API Configuration Environment Variables (Bash) Source: https://context7.com/muetze42/hellofresh-database/llms.txt Defines essential environment variables for configuring the API connection. These variables specify the API domain, path, rate limits, version, and the domain for the API portal. They are typically stored in a .env file for easy management. ```bash # API Configuration (.env) API_DOMAIN_NAME=api.hfresh.info # API subdomain API_PATH= # URL prefix for API routes (optional) API_RATE_LIMIT=60 # Requests per minute per user API_VERSION=0.9.0 # Current API version API_PORTAL_DOMAIN_NAME=console.hfresh.info # API Portal subdomain API_PORTAL_NAME="API + Data Portal" # Portal display name ``` -------------------------------- ### Run Background Jobs Launcher (Artisan) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Executes the Artisan command to launch background jobs. This command provides an interactive menu to select and dispatch various background tasks, such as data importing and statistics updates. ```bash php artisan app:launcher ``` -------------------------------- ### Build Assets (PNPM) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Builds project assets using PNPM. This command compiles and bundles frontend assets required for the application. ```bash pnpm run build ``` -------------------------------- ### List Recipes - Bash Source: https://context7.com/muetze42/hellofresh-database/llms.txt Fetches a paginated list of recipes for a specified country and locale. It supports various filtering options such as search terms, tags, labels, difficulty level, PDF availability, and sorting. The request is made to the /{country-locale}/recipes endpoint. ```bash # Get recipes for Germany in German curl -X GET "https://api.hfresh.info/de-DE/recipes?perPage=10&search=pasta&difficulty=1&has_pdf=true" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` -------------------------------- ### List Recipes Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves a paginated list of recipes for a specific country and locale. Supports filtering by tag, label, difficulty, PDF availability, and text search. ```APIDOC ## GET /{country}-{locale}/recipes ### Description Returns a paginated list of recipes for a specific country and locale. Supports filtering by tag, label, difficulty, PDF availability, and text search. ### Method GET ### Endpoint `/{country}-{locale}/recipes` ### Parameters #### Path Parameters - **country** (string) - Required - The country code (e.g., "de", "gb"). - **locale** (string) - Required - The locale code (e.g., "DE", "EN"). #### Query Parameters - **Authorization** (string) - Required - Bearer token for authentication. - **Accept** (string) - Optional - `application/json` - **perPage** (integer) - Optional - Number of recipes per page (10-200, default: 50). - **search** (string) - Optional - Text search in recipe name and headline. - **tag** (integer) - Optional - Filter by tag ID. - **label** (integer) - Optional - Filter by label ID. - **difficulty** (integer) - Optional - Filter by difficulty level (1: Easy, 2: Medium, 3: Hard). - **has_pdf** (boolean) - Optional - Filter recipes with PDF cards (`true` or `false`). - **sort** (string) - Optional - Sort order (`created_at` or `updated_at`, descending). ### Request Example ```bash curl -X GET "https://api.hfresh.info/de-DE/recipes?perPage=10&search=pasta&difficulty=1&has_pdf=true" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (array) - An array of recipe objects. - **id** (integer) - The unique identifier for the recipe. - **canonical_id** (integer) - The canonical ID of the recipe. - **variant** (boolean) - Indicates if this is a recipe variant. - **url** (string) - The URL to the recipe on the HelloFresh website. - **name** (string) - The name of the recipe. - **headline** (string) - A short headline for the recipe. - **description** (string) - A detailed description of the recipe. - **difficulty** (integer) - The difficulty level (1: Easy, 2: Medium, 3: Hard). - **prep_time** (integer) - The preparation time in minutes. - **total_time** (integer) - The total time in minutes. - **pdf_url** (string) - The URL to the PDF recipe card. - **has_pdf** (boolean) - Indicates if a PDF card is available. - **nutrition** (object) - Nutritional information. - **calories** (integer) - Calories per serving. - **protein** (integer) - Protein per serving (grams). - **carbohydrates** (integer) - Carbohydrates per serving (grams). - **fat** (integer) - Fat per serving (grams). - **label** (object) - The primary label for the recipe. - **id** (integer) - The label ID. - **name** (string) - The name of the label. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. - **tags** (array) - An array of tag objects associated with the recipe. - **id** (integer) - The tag ID. - **name** (string) - The name of the tag. - **created_at** (string) - Timestamp of creation. - **updated_at** (string) - Timestamp of last update. - **created_at** (string) - Timestamp of when the recipe was created. - **updated_at** (string) - Timestamp of when the recipe was last updated. - **meta** (object) - Pagination metadata. - **current_page** (integer) - The current page number. - **from** (integer) - The starting item index for the current page. - **last_page** (integer) - The total number of pages. - **per_page** (integer) - The number of items per page. - **to** (integer) - The ending item index for the current page. - **total** (integer) - The total number of items. #### Response Example ```json { "data": [ { "id": 12345, "canonical_id": 12340, "variant": false, "url": "https://hfresh.info/de-DE/recipes/cremige-pasta-12345", "name": "Cremige Pasta", "headline": "Mit frischem Basilikum", "description": "Ein schnelles und leckeres Pasta-Gericht...", "difficulty": 1, "prep_time": 15, "total_time": 30, "pdf_url": "https://hellofresh.com/recipe-cards/12345.pdf", "has_pdf": true, "nutrition": { "calories": 650, "protein": 25, "carbohydrates": 80, "fat": 22 }, "label": { "id": 5, "name": "Vegetarisch", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z" }, "tags": [ { "id": 12, "name": "Schnell", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z" } ], "created_at": "2024-01-15T10:30:00.000000Z", "updated_at": "2024-01-20T14:22:00.000000Z" } ], "meta": { "current_page": 1, "from": 1, "last_page": 542, "per_page": 10, "to": 10, "total": 5420 } } ``` ``` -------------------------------- ### PHP Code Quality and Formatting Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Maintain code quality and consistency by running specific tools in a defined order. This process includes initial formatting, automated refactoring, and final formatting to ensure modern PHP patterns and Laravel best practices are applied. ```bash vendor/bin/pint --dirty vendor/bin/rector vendor/bin/pint --dirty ``` -------------------------------- ### Pagination Configuration (PHP) Source: https://context7.com/muetze42/hellofresh-database/llms.txt Configures pagination settings for the API in a PHP environment, likely within a Laravel application. It defines the default, maximum, and minimum number of items per page, and also includes the API rate limit, which can be overridden by environment variables. ```php // config/api.php return [ 'pagination' => [ 'per_page_default' => 50, // Default items per page 'per_page_max' => 200, // Maximum allowed 'per_page_min' => 10, // Minimum allowed ], 'rate_limit' => env('API_RATE_LIMIT', 60), ]; ``` -------------------------------- ### Create PHPUnit Test Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Command to create a new PHPUnit test class using the Artisan command. This is the standard way to generate test files in the application. ```bash php artisan make:test --phpunit {name} ``` -------------------------------- ### Run PHPStan Static Analysis (Composer) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Performs static analysis on PHP code using PHPStan. This helps in detecting type errors and other potential issues before runtime. ```bash vendor/bin/phpstan ``` -------------------------------- ### Filter and Run Specific Test Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Command to run a specific test by its name. This is the recommended approach after making changes to a related file to quickly verify functionality. ```bash php artisan test --compact --filter=testName ``` -------------------------------- ### Format Code with Pint (Composer) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Formats PHP code according to the PSR-12 standard using Pint. This ensures code style consistency across the project. ```bash vendor/bin/pint ``` -------------------------------- ### Run Rector Static Analysis (Composer) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Applies automated code refactoring and analysis using Rector. This helps in maintaining code quality and modernizing the codebase. ```bash vendor/bin/rector ``` -------------------------------- ### List Available Countries Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves a paginated list of all active HelloFresh countries, including counts of recipes and ingredients for each country. This endpoint does not require localization parameters. ```APIDOC ## GET /countries ### Description Returns a paginated list of all active HelloFresh countries with recipe and ingredient counts. ### Method GET ### Endpoint /countries ### Parameters #### Query Parameters - **Authorization** (string) - Required - Bearer token for authentication. - **Accept** (string) - Optional - `application/json` ### Request Example ```bash curl -X GET "https://api.hfresh.info/countries" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (array) - An array of country objects. - **id** (integer) - The unique identifier for the country. - **code** (string) - The country code (e.g., "DE", "GB"). - **recipes_count** (integer) - The number of recipes available for this country. - **ingredients_count** (integer) - The number of ingredients available for this country. - **created_at** (string) - Timestamp of when the record was created. - **updated_at** (string) - Timestamp of when the record was last updated. - **meta** (object) - Pagination metadata. - **current_page** (integer) - The current page number. - **from** (integer) - The starting item index for the current page. - **last_page** (integer) - The total number of pages. - **per_page** (integer) - The number of items per page. - **to** (integer) - The ending item index for the current page. - **total** (integer) - The total number of items. #### Response Example ```json { "data": [ { "id": 1, "code": "DE", "recipes_count": 5420, "ingredients_count": 890, "created_at": "2024-01-15T10:30:00.000000Z", "updated_at": "2024-01-20T14:22:00.000000Z" }, { "id": 2, "code": "GB", "recipes_count": 4850, "ingredients_count": 756, "created_at": "2024-01-15T10:30:00.000000Z", "updated_at": "2024-01-20T14:22:00.000000Z" } ], "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 16, "total": 16 } } ``` ``` -------------------------------- ### Seed Countries Data (Artisan) Source: https://github.com/muetze42/hellofresh-database/blob/main/CONTRIBUTING.md Seeds the database with country data using a specific Artisan seeder class. This is necessary for populating initial geographical information. ```bash php artisan db:seed --class=CountrySeeder ``` -------------------------------- ### List Labels API Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves a list of recipe labels (dietary categories) for a specified country. This is useful for filtering recipes based on dietary preferences. ```APIDOC ## GET /labels ### Description Returns recipe labels (dietary categories) for a specific country. ### Method GET ### Endpoint `/{locale}-{country}/labels` ### Parameters #### Path Parameters - **locale** (string) - Required - The locale code (e.g., 'en'). - **country** (string) - Required - The country code (e.g., 'GB'). #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://api.hfresh.info/en-GB/labels" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (array) - An array of label objects. - **id** (integer) - The unique identifier for the label. - **name** (string) - The name of the label (e.g., 'Vegetarian'). - **created_at** (string) - Timestamp when the label was created. - **updated_at** (string) - Timestamp when the label was last updated. - **meta** (object) - Pagination metadata. - **current_page** (integer) - The current page number. - **from** (integer) - The starting item number for the current page. - **last_page** (integer) - The total number of pages. - **per_page** (integer) - The number of items per page. - **to** (integer) - The ending item number for the current page. - **total** (integer) - The total number of items. #### Response Example ```json { "data": [ {"id": 1, "name": "Vegetarian", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 2, "name": "Vegan", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 3, "name": "Family Friendly", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"} ], "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 8, "total": 8 } } ``` ``` -------------------------------- ### List Allergens API Source: https://context7.com/muetze42/hellofresh-database/llms.txt Retrieves a list of all allergens tracked for recipes in a specific country. This is useful for users with dietary restrictions or allergies. ```APIDOC ## GET /allergens ### Description Returns all allergens tracked for recipes in a specific country. ### Method GET ### Endpoint `/{locale}-{country}/allergens` ### Parameters #### Path Parameters - **locale** (string) - Required - The locale code (e.g., 'fr'). - **country** (string) - Required - The country code (e.g., 'FR'). #### Query Parameters None #### Request Body None ### Request Example ```bash curl -X GET "https://api.hfresh.info/fr-FR/allergens" \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Accept: application/json" ``` ### Response #### Success Response (200) - **data** (array) - An array of allergen objects. - **id** (integer) - The unique identifier for the allergen. - **name** (string) - The name of the allergen (e.g., 'Gluten'). - **created_at** (string) - Timestamp when the allergen was created. - **updated_at** (string) - Timestamp when the allergen was last updated. - **meta** (object) - Pagination metadata. - **current_page** (integer) - The current page number. - **from** (integer) - The starting item number for the current page. - **last_page** (integer) - The total number of pages. - **per_page** (integer) - The number of items per page. - **to** (integer) - The ending item number for the current page. - **total** (integer) - The total number of items. #### Response Example ```json { "data": [ {"id": 1, "name": "Gluten", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 2, "name": "Oeufs", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 3, "name": "Lait", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"}, {"id": 4, "name": "Fruits à coque", "created_at": "2024-01-10T08:00:00.000000Z", "updated_at": "2024-01-10T08:00:00.000000Z"} ], "meta": { "current_page": 1, "from": 1, "last_page": 1, "per_page": 50, "to": 14, "total": 14 } } ``` ``` -------------------------------- ### Extending Theme in Tailwind CSS v4 Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md Demonstrates how to extend the theme in Tailwind CSS v4 using the `@theme` directive within a CSS file. This replaces the `tailwind.config.js` file from previous versions. ```css @theme { --color-brand: oklch(0.72 0.11 178); } ``` -------------------------------- ### Livewire: Add `wire:key` to `@foreach` Loops Source: https://github.com/muetze42/hellofresh-database/blob/main/CLAUDE.md To ensure efficient DOM updates in Livewire components, always add a unique `wire:key` attribute to the first element within `@foreach` loops. This key should ideally be the item's ID for uniqueness. If an ID is not available, the loop index can be used. ```blade @foreach($posts as $post)
...
@endforeach ```