Skip to content

Instantly share code, notes, and snippets.

@lksudha
Created May 3, 2025 13:01
Show Gist options
  • Save lksudha/d01c15457ed4c1ae0eabaa0a51e29b4d to your computer and use it in GitHub Desktop.
Save lksudha/d01c15457ed4c1ae0eabaa0a51e29b4d to your computer and use it in GitHub Desktop.
chatgpt template for CI migration prompt

πŸ“„ Prompt Template: Legacy PHP to CodeIgniter 4.6 Page Migration

βœ… Goal:

I want to migrate the legacy PHP page [legacy_page.php] to CodeIgniter 4.6.

βœ… Expectations:

  • Follow MVC style used in the existing page [driver_payments.php]
  • The controller method should be named: [methodName]
  • The controller is located in: DispatchController under app/Controllers/Dispatch/Pages
  • The view is placed at: app/Views/Pages/[new_view_name].php
  • The API should return data for DataTables in pages of 100 rows
  • Do NOT use layout extensions (no <?= $this->extend(...) ?>)
  • Match the form layout, filter positioning, and structure of driver_payments.php exactly
  • Use render_select() helper for all dropdowns

βœ… Filters:

  • Include the following filters, in this order:
    1. Active Drivers (name: driver_active)
    2. Finished Drivers (name: driver_finished)
    3. Suppliers (name: supplier)
    4. Category
    5. Status
  • All dropdowns must be visible by default β€” do not implement any hide/show logic
  • All filter names must be unique; send only one assignedTo value to the API based on whichever is filled

βœ… API Details:

  • Create a new API method under App\Controllers\Api
  • Route should be added to the api route group
  • Use POST method unless explicitly asked to use GET
  • API must use models (no raw SQL in controller)
  • Use DriverModel::getDriverNameById() and SupplierModel::getSupplierNameById() to format names

βœ… Routes:

  • Add a route to the dispatch group: /dispatch/[page-url]
  • Add a route to the api group: /api/[resource-name]/list

βœ… Helper Usage:

  • Reuse existing render_select() for all dropdowns
  • Use existing DriverModel and SupplierModel where applicable
  • View must follow the same card and Bootstrap layout as driver_payments.php

βœ… Testing Plan:

I will test this by:

  • Visiting the dropdown link from dispatch home
  • Checking that all filters appear in the specified order
  • Validating the complaints table loads correctly via AJAX
  • Verifying correct driver/supplier names in AssignedTo column

πŸ“‚ Reference Files (uploaded separately):

  • Legacy PHP file: [complaints.php]
  • Reference page layout: [driver_payments.php]
  • Routes file: [Routes.php]
  • API sample: [DriverPayments.php]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment