4.0 KiB
4.0 KiB
Walkthrough — Truck Status Management
We have successfully implemented the ability to edit and delete trucks from the admin dashboard, enforced Plate number read-only behavior post-creation, and automated active trip cancellation and collection team unassignment when a truck is moved to a non-active status (maintenance or retired).
Changes Made
1. Backend Changes
- Request Validation: Updated StoreTruckRequest.php to ignore the current truck's ID when validating the unique
plate_numberconstraint during updates. - Controller Logic: Extended
update()in AdminTruckController.php:- When the truck status is updated from
activeto a non-active status (maintenanceorretired), any active/scheduled trips (scheduled,in_progress,at_dumpsite) for that truck are automatically marked ascancelledwith a system note. - The truck is unassigned from any active collection teams (setting
truck_idtonullon the team).
- When the truck status is updated from
2. Frontend Changes
- Table Actions: Added an Actions column with an Edit button to the trucks list inside trucks.blade.php.
- Edit & Delete slide-over modal:
- Re-used the existing form structure for edit mode.
- Configured the plate number input field to be read-only (and visually styled as disabled) in edit mode.
- Added a Delete button at the bottom of the form when editing a truck, complete with an interactive confirm dialog.
- Form submit handler automatically switches between
POST(create) andPATCH(update) based on the context.
Walkthrough - Partner Store Portal Overhaul
I have successfully enhanced the Partner Store Portal with advanced search, LGU-scoped pricing, and professional PDF receipts.
Key Changes
1. Dynamic LGU Pricing
- Added
qr_retail_price_centavosto thetenantstable. - Each LGU can now set its own retail price for QR stickers.
- The Store Portal automatically fetches and displays the correct price for the current store's LGU.
2. Enhanced Household Search
- Integrated TomSelect for a lightning-fast, searchable dropdown.
- Search results are strictly scoped to the store's LGU.
- Added Leaflet.js map verification to show the resident's location upon selection.
3. Professional PDF Receipts
- Implemented professional receipt generation using DomPDF.
- Receipts include store details, transaction numbers, and branded formatting.
- Added a "Download Receipt" flow immediately after a successful sale.
Technical Implementation
- Migrations: Added pricing field to
tenants. - Controllers: Updated
StorePortalControllerwithsettings,search, anddownloadReceiptmethods. - Frontend: Overhauled
sales.blade.phpwith modern JS libraries and premium styling. - Security: Implemented
StoreSalePolicyto prevent unauthorized receipt downloads.
Verification Results
Automated Tests
Created and ran a new test file: AdminTruckCrudTest.php
All test cases pass successfully:
PASS Tests\Feature\Api\V1\Admin\AdminTruckCrudTest
✓ admin can update truck details 14.39s
✓ admin updating plate uniqueness checks 0.16s
✓ changing status to maintenance cancels trips and unassigns teams 0.18s
✓ admin can delete truck 0.10s
Tests: 4 passed (13 assertions)
Duration: 15.17s
Frontend Assets
Built the frontend assets successfully via Vite compilation:
✓ built in 3.40s