diff --git a/CHANGELOG.md b/CHANGELOG.md index e96e2c60..83deb07f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,3 +3,4 @@ - Fixed incorrect aggregation in monthly and yearly statistics. - Adjusted footer contact information font style for better readability. - Added frontend menu management system in administrator module (navbar and left menu positions). +- Added 'icon' support for frontend menu management. diff --git a/backend/modules/administrator/views/menu-frontend/_form.php b/backend/modules/administrator/views/menu-frontend/_form.php index 352921c8..dac4b174 100644 --- a/backend/modules/administrator/views/menu-frontend/_form.php +++ b/backend/modules/administrator/views/menu-frontend/_form.php @@ -15,10 +15,13 @@ use yii\helpers\ArrayHelper;
' . Html::encode($model->icon) . ')' : null,
+ ],
'link',
[
'attribute' => 'position',
diff --git a/common/models/CmsMenuFrontend.php b/common/models/CmsMenuFrontend.php
index 23f27f76..787fc4e8 100644
--- a/common/models/CmsMenuFrontend.php
+++ b/common/models/CmsMenuFrontend.php
@@ -11,6 +11,7 @@ use yii\behaviors\TimestampBehavior;
* @property int $id
* @property int|null $parent_id
* @property string $name
+ * @property string|null $icon
* @property string|null $link
* @property string $position navbar, left_menu
* @property int|null $sort_order
@@ -50,6 +51,7 @@ class CmsMenuFrontend extends \yii\db\ActiveRecord
[['parent_id', 'sort_order', 'status', 'created_at', 'updated_at'], 'integer'],
[['name', 'position'], 'required'],
[['name', 'link'], 'string', 'max' => 255],
+ [['icon'], 'string', 'max' => 100],
[['position'], 'string', 'max' => 50],
[['parent_id'], 'exist', 'skipOnError' => true, 'targetClass' => CmsMenuFrontend::class, 'targetAttribute' => ['parent_id' => 'id']],
];
@@ -64,6 +66,7 @@ class CmsMenuFrontend extends \yii\db\ActiveRecord
'id' => 'ID',
'parent_id' => 'เมนูหลัก',
'name' => 'ชื่อเมนู',
+ 'icon' => 'ไอคอน (เช่น fa fa-home)',
'link' => 'ลิงก์',
'position' => 'ตำแหน่ง',
'sort_order' => 'ลำดับ',
diff --git a/console/migrations/m260227_023007_add_icon_column_to_cms_menu_frontend_table.php b/console/migrations/m260227_023007_add_icon_column_to_cms_menu_frontend_table.php
new file mode 100644
index 00000000..f6606ce3
--- /dev/null
+++ b/console/migrations/m260227_023007_add_icon_column_to_cms_menu_frontend_table.php
@@ -0,0 +1,25 @@
+addColumn('{{%cms_menu_frontend}}', 'icon', $this->string(100)->after('name'));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function safeDown()
+ {
+ $this->dropColumn('{{%cms_menu_frontend}}', 'icon');
+ }
+}