# Manual Edits Required (grocery-api)

Apply these changes locally. The tooling could not write to some files (permission limits).

---

## 1. Slider routes and navigation

### 1a. `routes/admin.php`

- **After** the line `use App\Http\Controllers\Admin\SettingsController;` add:
  ```php
  use App\Http\Controllers\Admin\SliderController;
  ```

- **After** the line `Route::resource('pages', PageController::class);` (inside the protected admin group) add:
  ```php
  Route::resource('sliders', SliderController::class);
  ```

### 1b. `resources/views/admin/partials/sidebar.blade.php`

- In the **Content** section, **before** the "Pages" link, add a **Sliders** link. Find:
  ```html
  <li class="pt-4">
      <p class="px-4 text-xs font-semibold text-gray-400 uppercase">Content</p>
  </li>
  <li>
      <a href="{{ route('admin.pages.index') }}" ...
  ```
  Insert this **new** `<li>` between the "Content" heading and the Pages `<li>`:
  ```html
  <li>
      <a href="{{ route('admin.sliders.index') }}" class="flex items-center px-4 py-2 rounded hover:bg-gray-700 {{ request()->routeIs('admin.sliders.*') ? 'bg-gray-700' : '' }}">
          <i class="fas fa-images w-5 mr-3"></i>
          Sliders
      </a>
  </li>
  ```

### 1c. `routes/api.php`

- **After** `use App\Http\Controllers\Api\V1\ProductController;` add:
  ```php
  use App\Http\Controllers\Api\V1\SliderController;
  ```

- Under **Public routes**, **after** `Route::get('/products/{product}', [ProductController::class, 'show']);` add:
  ```php
  Route::get('/sliders', [SliderController::class, 'index']);
  ```

---

## 2. Theme API route (app fetches theme from admin)

### 2a. `routes/api.php`

- **After** `use App\Http\Controllers\Api\V1\SliderController;` add:
  ```php
  use App\Http\Controllers\Api\V1\ThemeController;
  ```

- Under **Public routes**, add:
  ```php
  Route::get('/theme', [ThemeController::class, 'show']);
  ```

---

## 3. Admin: option to change app theme

### 3a. `app/Http/Controllers/Admin/SettingsController.php`

- Add **app_theme** to the `$settingKeys` array (if you already have `$settingKeys` from the settings fix). Add this entry:
  ```php
  'app_theme' => ['type' => 'text', 'group' => 'app'],
  ```

- If you **do not** have `$settingKeys` yet (settings update not applied), first add the full settings fix from `ADMIN_SETTINGS_AND_SLIDERS_EDITS.md` (Section 1), then add the `app_theme` line above to that array.

### 3b. `resources/views/admin/settings/index.blade.php`

- **Before** the "Save Settings" button (before `<div class="flex justify-end">`), add a new **App Theme** section:
  ```html
  <!-- App Theme (mobile app) -->
  <div>
      <h3 class="text-lg font-semibold mb-4 border-b pb-2">App Theme</h3>
      <p class="text-sm text-gray-500 mb-3">Theme applied in the mobile app (Home, Login, etc.). Users see it after refreshing.</p>
      <div class="max-w-xs">
          <label for="app_theme" class="block text-sm font-medium text-gray-700">Theme</label>
          <select name="app_theme" id="app_theme" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3">
              <option value="blinkit" {{ old('app_theme', \App\Models\Setting::get('app_theme', 'blinkit')) == 'blinkit' ? 'selected' : '' }}>Blinkit (Yellow/Green)</option>
              <option value="dark" {{ old('app_theme', \App\Models\Setting::get('app_theme', 'blinkit')) == 'dark' ? 'selected' : '' }}>Dark</option>
              <option value="light" {{ old('app_theme', \App\Models\Setting::get('app_theme', 'blinkit')) == 'light' ? 'selected' : '' }}>Light (Blue)</option>
          </select>
      </div>
  </div>
  ```

### 3c. Seed default app theme (optional)

- In `database/seeders/SettingsSeeder.php`, inside the `$settings` array, add:
  ```php
  ['key' => 'app_theme', 'value' => 'blinkit', 'type' => 'text', 'group' => 'app'],
  ```
  Then run: `php artisan db:seed --class=SettingsSeeder`  
  Or insert manually: `INSERT INTO settings (key, value, type, `group`, created_at, updated_at) VALUES ('app_theme', 'blinkit', 'text', 'app', NOW(), NOW());`

---

## 4. Run migrations (if not done)

```bash
cd grocery-api
php artisan migrate
```

---

## Summary

| Item | File(s) |
|------|--------|
| Slider routes + sidebar | admin.php, sidebar.blade.php, api.php |
| Theme API | api.php, ThemeController.php (already created) |
| Admin theme option | SettingsController.php ($settingKeys), settings/index.blade.php, optional seeder |

After editing, Sliders will appear in the admin sidebar under Content, and **Settings** will have an **App Theme** dropdown. The app will read the theme from `GET /api/v1/theme` and apply Blinkit / Dark / Light.
