update marketing
All checks were successful
All checks were successful
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# Walkthrough - PostgreSQL Compatibility Fixes
|
||||
|
||||
I have resolved the 500 Internal Server Error encountered when fetching dashboard data. The issue was caused by MySQL-specific SQL syntax in the backend controllers, which is incompatible with your PostgreSQL database.
|
||||
|
||||
## Changes Made
|
||||
|
||||
### Backend API
|
||||
|
||||
#### 1. Statistics Controller Fix
|
||||
Updated [StatisticsController.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/app/Http/Controllers/Api/StatisticsController.php) to use PostgreSQL's `TO_CHAR` function and **double-quoted camelCase column names** like `"totalAmount"`.
|
||||
|
||||
**Before:**
|
||||
```php
|
||||
$sales_data = Sale::selectRaw("DATE_FORMAT(created_at, '%Y-%m-%d') as date, SUM(totalAmount) as amount")
|
||||
```
|
||||
|
||||
**After:**
|
||||
```php
|
||||
$sales_data = Sale::selectRaw("TO_CHAR(created_at, 'YYYY-MM-DD') as date, SUM(\"totalAmount\") as amount")
|
||||
```
|
||||
|
||||
#### 2. Report Controller Fix
|
||||
Updated [AcnooReportController.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/app/Http/Controllers/Api/AcnooReportController.php) to use the PostgreSQL cast operator `::date` and quoted camelCase columns (`"saleDate"`, `"lossProfit"`, etc.).
|
||||
|
||||
**Example After:**
|
||||
```php
|
||||
DB::raw('"saleDate"::date as date')
|
||||
DB::raw('SUM("lossProfit") as total_sale_income')
|
||||
```
|
||||
|
||||
#### 3. Other Database Compatibility Fixes
|
||||
- **Admin Dashboard:** Replaced `MONTHNAME()` with `TO_CHAR(..., 'Month')` in [DashboardController.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/app/Http/Controllers/Admin/DashboardController.php).
|
||||
- **Transfer Model:** Replaced `CAST(... AS UNSIGNED)` with `CAST(... AS INTEGER)` in [Transfer.php](file:///media/itc43/Data/OTHER_PROJECT/kulakpos/kulakpos_15Maret2026_to%20GTEA/public_html/app/Models/Transfer.php).
|
||||
|
||||
## Verification Results
|
||||
|
||||
### Manual Verification Required
|
||||
As the backend environment is restricted, please perform the following steps to verify the fix:
|
||||
1. Ensure your PostgreSQL database is running.
|
||||
2. Restart your Laravel development server: `php artisan serve`.
|
||||
3. Run your Flutter application and navigate to the dashboard.
|
||||
4. Verify that the "Failed to fetch business data 500" error no longer appears and that data is displayed correctly.
|
||||
Reference in New Issue
Block a user