# Laravel Backend Migration Plan - ZIPO System

## Phase 1: Project Setup ✅
- [x] Create Laravel project
- [x] Configure MySQL database
- [x] Install Sanctum
- [x] Generate app key
- [x] Fix Property.php unclosed bracket

## Phase 2: Migrations (Database Schema) ✅
- [x] Create migrations for all tables
- [x] Run migrations

## Phase 3: Models ✅
- [x] User (with roles: landlord, tenant, super_admin, property_manager, accountant, support_agent, technician)
- [x] Property
- [x] Unit
- [x] Meter
- [x] MeterReading
- [x] Transaction
- [x] Wallet
- [x] Alert
- [x] SupportTicket
- [x] DisconnectionLog
- [x] SystemConfig

## Phase 4: Controllers (API) ✅
- [x] AuthController (register, login, forgot/reset password, profile CRUD, photo upload)
- [x] PropertyController (CRUD with landlord scoping)
- [x] UnitController (CRUD + assign tenant)
- [x] MeterController (CRUD, toggle relay, receive ESP32 readings, live reading)
- [x] MeterReadingController (list readings with date filters)
- [x] TransactionController (CRUD, processTenantPayment with auto-tax deduction)
- [x] WalletController (get balance, update momo, tenant balance)
- [x] TenantController (list by landlord/admin, toggle connection)
- [x] LandlordController (list by admin, update status)
- [x] AlertController (CRUD, mark read, mark all read)
- [x] SupportTicketController (CRUD with status/priority filters)
- [x] DisconnectionController (log, reconnect, status filter)
- [x] ReportController (dashboard summary, financial report, meter health)
- [x] SystemConfigController (get/update config values)

## Phase 5: API Routes ✅
- [x] Create api.php routes (30+ endpoints)
- [x] Register in bootstrap/app.php
- [x] Sanitize middleware for JSON responses
- [x] Public: auth, ESP32 readings, system config
- [x] Protected: all CRUD + business logic

## Phase 6: Testing (Pending)
- [ ] Run `php artisan config:cache`
- [ ] Run `php artisan route:list` to verify routes
- [ ] Test register endpoint
- [ ] Test login endpoint
- [ ] Test protected endpoints

## Phase 7: Namecheap Deployment (Paused — DNS blocker)
- [x] Database created on Namecheap: `ofrijqsq_zipo_database`
- [x] DB user: `ofrijqsq_zipo_system` / password: `zipometer2026`
- [x] SQL schema imported (all tables + admin seed + system configs)
- [x] Production `.env` embedded in `laravel-backend-deploy.zip`
- [x] APP_URL set to `https://tijofriq.store`
- [x] Files uploaded & extracted to `public_html/laravel-backend/`
- [x] Storage & bootstrap/cache permissions set to 755
- [x] PHP 8.3+ selected
- [ ] ⚠️ BLOCKED: Domain `tijofriq.store` has no DNS nameservers — set `dns1/dns2.namecheaphosting.com` at Namecheap registrar
- [ ] Once DNS resolves: test `https://tijofriq.store/laravel-backend/public/api/system-config`
- [ ] Update Flutter apps baseUrl
- [ ] Test login with `admin@zipo.com` / `password123`

## Phase 8: InfinityFree Deployment (IN PROGRESS — current)
- [x] Domain: `ziposystem.great-site.net`
- [x] DB: `sql306.infinityfree.com` / `if0_42599145_ziposystem_db` / user `if0_42599145`
- [x] Built `laravel-backend-infinityfree.zip` with configured `.env` (APP_URL + DB creds + APP_KEY)
- [x] Created `INFINITYFREE_DEPLOY.md` step-by-step guide
- [ ] Import `database/zipo_database.sql` into InfinityFree phpMyAdmin
- [ ] Set PHP version 8.3+
- [ ] Upload `laravel-backend-infinityfree.zip` to `htdocs` and extract
- [ ] Set storage & bootstrap/cache permissions (755)
- [ ] Test `https://ziposystem.great-site.net/laravel-backend/public/api/system-config`
- [ ] Update Flutter apps baseUrl to `https://ziposystem.great-site.net/laravel-backend/public/api`
- [ ] Test login with `admin@zipo.com` / `password123`

