fix: add city_auto_u migration and fix HospitalProfile upload mkdir error
- Add migration 2026-03-18-000028_CreateCityAutoUTable.php to create the missing city_auto_u table (city, district, state columns) used by PatientModel::getCitySuggestions() — resolves 500 on /billing/patient/city - Fix HospitalProfile::save() to check directory creation success before moving uploaded logo files; returns clean JSON error instead of throwing HTTPException when public/assets/images/ is not writable
This commit is contained in:
parent
df8c4c417c
commit
1856d990eb
|
|
@ -110,7 +110,15 @@ class HospitalProfile extends BaseController
|
|||
|
||||
$targetDir = FCPATH . 'assets/images';
|
||||
if (! is_dir($targetDir)) {
|
||||
@mkdir($targetDir, 0775, true);
|
||||
mkdir($targetDir, 0775, true);
|
||||
}
|
||||
if (! is_dir($targetDir)) {
|
||||
return $this->response->setJSON([
|
||||
'update' => 0,
|
||||
'error_text' => 'Cannot create upload directory. Check server write permissions.',
|
||||
'csrfName' => csrf_token(),
|
||||
'csrfHash' => csrf_hash(),
|
||||
]);
|
||||
}
|
||||
|
||||
$newName = 'hospital_logo_' . date('Ymd_His') . '_' . substr(md5((string) mt_rand()), 0, 8) . '.' . $ext;
|
||||
|
|
@ -144,7 +152,15 @@ class HospitalProfile extends BaseController
|
|||
|
||||
$targetDir = FCPATH . 'assets/images';
|
||||
if (! is_dir($targetDir)) {
|
||||
@mkdir($targetDir, 0775, true);
|
||||
mkdir($targetDir, 0775, true);
|
||||
}
|
||||
if (! is_dir($targetDir)) {
|
||||
return $this->response->setJSON([
|
||||
'update' => 0,
|
||||
'error_text' => 'Cannot create upload directory. Check server write permissions.',
|
||||
'csrfName' => csrf_token(),
|
||||
'csrfHash' => csrf_hash(),
|
||||
]);
|
||||
}
|
||||
|
||||
$newName = 'pharmacy_logo_' . date('Ymd_His') . '_' . substr(md5((string) mt_rand()), 0, 8) . '.' . $ext;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class CreateCityAutoUTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => [
|
||||
'type' => 'INT',
|
||||
'unsigned' => true,
|
||||
'auto_increment' => true,
|
||||
],
|
||||
'city' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 150,
|
||||
'default' => '',
|
||||
],
|
||||
'district' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 150,
|
||||
'default' => '',
|
||||
],
|
||||
'state' => [
|
||||
'type' => 'VARCHAR',
|
||||
'constraint' => 100,
|
||||
'default' => '',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->forge->addKey('id', true);
|
||||
$this->forge->addKey(['city', 'district', 'state']);
|
||||
|
||||
$this->forge->createTable('city_auto_u', true);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('city_auto_u', true);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"generated_at": "2026-03-17 23:43:07",
|
||||
"generated_at": "2026-03-18 00:28:48",
|
||||
"source": "local-current-db",
|
||||
"tables": {
|
||||
"ai_demo_seed_log": [
|
||||
|
|
@ -1601,7 +1601,7 @@
|
|||
"record_id": "AZURE_OPENAI_API_KEY",
|
||||
"field_name": "AZURE_OPENAI_API_KEY",
|
||||
"old_value": "\"\"",
|
||||
"new_value": "\"__REDACTED_AZURE_OPENAI_KEY__\"",
|
||||
"new_value": "\"REDACTED_AZURE_OPENAI_API_KEY\"",
|
||||
"user_id": "1",
|
||||
"action_at": "2026-02-21 23:37:54",
|
||||
"hash": "b78cef4b60aded7c6d76659c3555ac2906b276f1e86ddd251e6270c03e0d90c7",
|
||||
|
|
@ -1640,7 +1640,7 @@
|
|||
"record_id": "AZURE_DOCINTEL_KEY",
|
||||
"field_name": "AZURE_DOCINTEL_KEY",
|
||||
"old_value": "\"\"",
|
||||
"new_value": "\"__REDACTED_AZURE_DOCINTEL_KEY__\"",
|
||||
"new_value": "\"REDACTED_AZURE_DOCINTEL_KEY\"",
|
||||
"user_id": "1",
|
||||
"action_at": "2026-02-21 23:37:54",
|
||||
"hash": "3473bc10900326acf7b2cb721de3bcaa23047b5eddcccb133ca7729eb8a62b6f",
|
||||
|
|
@ -1665,8 +1665,8 @@
|
|||
"module": "hospital_setting",
|
||||
"record_id": "AZURE_OPENAI_API_KEY",
|
||||
"field_name": "AZURE_OPENAI_API_KEY",
|
||||
"old_value": "\"__REDACTED_AZURE_OPENAI_KEY__\"",
|
||||
"new_value": "\"__REDACTED_AZURE_OPENAI_KEY__\"",
|
||||
"old_value": "\"REDACTED_AZURE_OPENAI_API_KEY\"",
|
||||
"new_value": "\"REDACTED_AZURE_OPENAI_API_KEY\"",
|
||||
"user_id": "1",
|
||||
"action_at": "2026-02-21 23:42:39",
|
||||
"hash": "b99952e255c4d243b4e2d2b931136bd1f4aa1b176e5be7da5c7806c7f569be73",
|
||||
|
|
@ -1704,8 +1704,8 @@
|
|||
"module": "hospital_setting",
|
||||
"record_id": "AZURE_DOCINTEL_KEY",
|
||||
"field_name": "AZURE_DOCINTEL_KEY",
|
||||
"old_value": "\"__REDACTED_AZURE_DOCINTEL_KEY__\"",
|
||||
"new_value": "\"__REDACTED_AZURE_DOCINTEL_KEY__\"",
|
||||
"old_value": "\"REDACTED_AZURE_DOCINTEL_KEY\"",
|
||||
"new_value": "\"REDACTED_AZURE_DOCINTEL_KEY\"",
|
||||
"user_id": "1",
|
||||
"action_at": "2026-02-21 23:42:39",
|
||||
"hash": "4722f3949ec7952fd15e7468b37913ed43c328bfbf289c3a3041790d58dbaf64",
|
||||
|
|
@ -23580,7 +23580,7 @@
|
|||
{
|
||||
"id": "26",
|
||||
"s_name": "AZURE_OPENAI_API_KEY",
|
||||
"s_value": "__REDACTED_AZURE_OPENAI_KEY__"
|
||||
"s_value": "REDACTED_AZURE_OPENAI_API_KEY"
|
||||
},
|
||||
{
|
||||
"id": "27",
|
||||
|
|
@ -23595,7 +23595,7 @@
|
|||
{
|
||||
"id": "29",
|
||||
"s_name": "AZURE_DOCINTEL_KEY",
|
||||
"s_value": "__REDACTED_AZURE_DOCINTEL_KEY__"
|
||||
"s_value": "REDACTED_AZURE_DOCINTEL_KEY"
|
||||
},
|
||||
{
|
||||
"id": "30",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user