当前位置:网站首页>Share the easy-to-use fastadmin open source system - practical part

Share the easy-to-use fastadmin open source system - practical part

2022-06-28 11:47:00 Programmer Xiao Peng

One 、 Preface

         Installation chapter : Share useful FastAdmin Open source system - Installation chapter Most companies have their own systems for internal use , Let customer service 、 Operational analysis data 、 View data usage , It is characterized by no complex business , Permission control is required , So we need a simple and convenient system . Today I will share with you the next PHP Open source background management system FastAdmin,FastAdmin It is very suitable for small and medium-sized background management systems , It can be used out of the box without secondary development , Suitable for the background of simple business , For example, you can view reports 、 Check the log 、 View records and other requirements , With my push , At present, our company has two back offices using the system .

Two 、 brief introduction

        FastAdmin It's based on ThinkPHP5+Bootstrap Rapid background development framework . The system has built-in permission control 、 One click generation CRUD、 One click to generate controller menu and rules 、 One click generation API Interface document and other functions , There are also rich plug-ins that can be downloaded and used , Ecological convenience, very good . Let's use it step by step .

3、 ... and 、 Onekey CRUD

3.1 Add data sheet

         To demonstrate CRUD function , We need a simple data sheet , perform SQL Statement to create a piece of data .

CREATE TABLE `fa_teacher` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` char(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT ' Teacher name ',
  `sex` tinyint(3) NOT NULL DEFAULT '1' COMMENT ' Gender  1: male  2: Woman ',
  `age` int(11) NOT NULL DEFAULT '0' COMMENT ' Age ',
  `switch` tinyint(1) NOT NULL DEFAULT '1' COMMENT ' On state  1: Turn on  0: close ',
  `create_time` int(11) NOT NULL DEFAULT '0' COMMENT ' Creation time ',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT=' The teacher table ';

After the data table is created successfully , Let's insert some data .

INSERT INTO `fastdemo`.`fa_teacher`(`id`, `name`, `sex`, `age`, `switch`, `create_time`) VALUES (1, ' Zhang San ', 1, 20, 1, 1644761811);
INSERT INTO `fastdemo`.`fa_teacher`(`id`, `name`, `sex`, `age`, `switch`, `create_time`) VALUES (2, ' Li Si ', 1, 21, 1, 1644761822);
INSERT INTO `fastdemo`.`fa_teacher`(`id`, `name`, `sex`, `age`, `switch`, `create_time`) VALUES (3, ' test ', 2, 22, 1, 1644761831);
INSERT INTO `fastdemo`.`fa_teacher`(`id`, `name`, `sex`, `age`, `switch`, `create_time`) VALUES (4, ' Wang Wu ', 1, 23, 1, 1644761844);

3.2 download CRUD plug-in unit

         We log in to the system background and click the plug-in management list , Search for crud, Click on the install , Note that you also need to log in to your official account . After successful installation, it will be displayed in the menu bar on the left “ Online command management ”, If not, clear the cache .

3.3 perform CRUD command

         Click the online command management menu on the left , Click Add , Generate in one click CRUD Under the tab, select the data table we want to generate , You can also select an association model to complete the join query . Field identification can be set , After setting, we scroll down , Turn to the bottom , Click execute now . You can view the execution results in the command management list .

Four 、 One click menu generation

         In the previous step, we generated by one click CRUD after , At this time, the code has been generated , Let's add a menu , Or click the Add button , Select the one click generate menu , Select the controller corresponding to the data table name generated in the previous step , That is to say Teacher.php controller , Click the execute now button , You can see the teacher management list on the left .

         We can see the previously inserted data records in the teacher management list , You can also add 、 Delete 、 edit 、 Search function .

5、 ... and 、 Analyze the source code

         View the requested address through the console shown above , Called teacher controller , Check the source code and find that there is no implementation in the controller crud, But inherited Backend.

        Teacher.php The controller inherits Backend controller ,Backend The controller is introduced into the controller traits Under the Backend.php.

         because traits\Backend Used trait,trait Is the solution PHP A code reuse mechanism prepared for single inheritance , Other classes do not inherit traits Under the Backend.php, As long as this class is referenced , You can use the methods in the class . This class implements the basic CRUD function , This eliminates the need to write duplicate code in each controller .

6、 ... and 、 Conclusion

         The introduction of this system ends here from installation to application , You can explore other functions by yourself , Thank you for reading , See you next time .

原网站

版权声明
本文为[Programmer Xiao Peng]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202161338597101.html