diff --git a/kernel/Widget.php b/kernel/Widget.php new file mode 100644 index 0000000..3ecbad8 --- /dev/null +++ b/kernel/Widget.php @@ -0,0 +1,34 @@ +cgView = new CgView(); + $this->cgView->viewPath = ROOT_DIR . "/views/widgets"; + + $this->data = $data; + + $this->init(); + } + + public function run() + { + } + + public static function create(array $data = []): Widget + { + return new static($data); + } + + protected function init() + { + } + +} \ No newline at end of file diff --git a/kernel/models/Menu.php b/kernel/models/Menu.php new file mode 100644 index 0000000..4429821 --- /dev/null +++ b/kernel/models/Menu.php @@ -0,0 +1,35 @@ + 'Родительский пункт меню', + 'icon_file' => 'Путь к иконке', + 'icon_font' => 'Иконка', + 'label' => 'Заголовок', + 'url' => 'URL', + 'status' => 'Статус', + ]; + } + + public static function getChild(int $id) + { + $collection = Menu::where("parent_id", $id)->get(); + if (!$collection->isEmpty()){ + return $collection; + } + + return false; + } +} \ No newline at end of file diff --git a/kernel/widgets/MenuWidget.php b/kernel/widgets/MenuWidget.php new file mode 100644 index 0000000..a0f3aaf --- /dev/null +++ b/kernel/widgets/MenuWidget.php @@ -0,0 +1,17 @@ +get(); + $this->cgView->render('/admin/menu.php', ['menu' => $menu]); + } + +} \ No newline at end of file diff --git a/migrations/2024_08_30_083939_create_menu_table.php b/migrations/2024_08_30_083939_create_menu_table.php new file mode 100644 index 0000000..99c4023 --- /dev/null +++ b/migrations/2024_08_30_083939_create_menu_table.php @@ -0,0 +1,34 @@ +schema->create('menu', function (Blueprint $table) { + $table->increments('id'); + $table->integer('parent_id')->default(0); + $table->string('icon_file', 255)->nullable(); + $table->string('icon_font', 255)->nullable(); + $table->string('label', 255); + $table->string('url', 255); + $table->integer('status')->default(1); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + \kernel\App::$db->schema->dropIfExists('menu'); + } +}; diff --git a/views/admin/layouts/main.php b/views/admin/layouts/main.php index a7f6f0e..c7783c9 100644 --- a/views/admin/layouts/main.php +++ b/views/admin/layouts/main.php @@ -21,46 +21,7 @@