# Cydekick Artisan Commands

Custom `php artisan` commands written for Cydekick one-off data tasks, migrations, and maintenance jobs. All commands live in `app/Console/Commands/`.

---

## How to run

### Locally (XAMPP)

```bash
cd c:\xampp\htdocs\Cydekick-bmp
php artisan <command-name> [options]
```

### On the server

SSH in, then:

```bash
cd /var/www/cydekick
php artisan <command-name> [options]
```

Always do a `--dry-run` first if the command supports it.

---

## Commands

---

### `inventory:clean-descriptions`

**File:** `app/Console/Commands/CleanDescriptionsCommand.php`

**What it does:**
Strips the embedded "Vehicle Fitment" table from product descriptions. When product data was originally imported from Allmakes, the fitment table was stored inline in the description field. Now that fitment data has its own dedicated table (`allmakes_psp_fitments`), the descriptions need cleaning.

The cleaner:
1. Splits the description at the first occurrence of `Vehicle Fitment`
2. Keeps only the text before it (the marketing intro sentence)
3. Strips any HTML tags (a small number of descriptions were `<p>` wrapped)
4. Decodes HTML entities (`&gt;` → `>`, `&amp;` → `&`)
5. Trims whitespace

Also checks `channel_listings.attributes.description` overrides for the same pattern.

**Scope (at time of writing):**
- 8,750 products affected (company_id = 2, Somerset4x4)
- 0 channel listing overrides needed cleaning

**Usage:**

```bash
# Preview — shows counts, writes nothing
php artisan inventory:clean-descriptions --dry-run

# Run for real (defaults to company_id = 2)
php artisan inventory:clean-descriptions

# Different company
php artisan inventory:clean-descriptions --company=3
```

**Options:**

| Option | Default | Description |
|--------|---------|-------------|
| `--company` | `2` | The `company_id` to process |
| `--dry-run` | off | Preview mode — no DB writes |

**Before / after example:**

Before:
```
This RADIATOR ASSEMBLY has been available... Fits DEFENDER 1986 - 2006.
Vehicle Fitment

Vehicle    Marque       Engine    Notes    Break From    Break To
DEFENDER   LAND ROVER   300Tdi    NONE     -             -
```

After:
```
This RADIATOR ASSEMBLY has been available... Fits DEFENDER 1986 - 2006.
```

**Safe to re-run:** Yes — products that no longer contain `Vehicle Fitment` are skipped.

---

<!-- Add new commands above this line, following the same format -->
