Laravel-admin 控制台命令

叶阳
2023-12-01

Laravel-admin内置了几个控制台命令来帮助开发,安装好laravel-admin之后,就可以直接使用它们了。
使用php artisan admin命令可以显示当前Laravel-admin的版本,以及列出所有可用的admin命令。

$ php artisan admin
    __                                __                __          _
   / /   ____ __________ __   _____  / /     ____ _____/ /___ ___  (_)___
  / /   / __ `/ ___/ __ `/ | / / _ \/ /_____/ __ `/ __  / __ `__ \/ / __ \
 / /___/ /_/ / /  / /_/ /| |/ /  __/ /_____/ /_/ / /_/ / / / / / / / / / /
/_____/\__,_/_/   \__,_/ |___/\___/_/      \__,_/\__,_/_/ /_/ /_/_/_/ /_/

Laravel-admin version 1.6.15

Available commands:
 admin:make              Make admin controller
 admin:menu              Show the admin menu
 admin:install           Install the admin package
 admin:publish           re-publish laravel-admin's assets, configuration, language and migration files. If you want overwrite the existing files, you can add the `--force` option
 admin:uninstall         Uninstall the admin package
 admin:import            Import a Laravel-admin extension
 admin:create-user       Create a admin user
 admin:reset-password    Reset password for a specific admin user
 admin:extend            Build a Laravel-admin extension
 admin:export-seed       Export seed a Laravel-admin database tables menu, roles and permissions
 admin:minify            Minify the CSS and JS
 admin:form              Make admin form widget

artisan admin:make

这个命令用来创建admin控制器,传入一个model,它会根据model对应表的字段,默认构建出所需的grid,form和show三个页面的代码,

$ php artisan admin:make PostController --model=App\\Post

// 在windows系统中
$ php artisan admin:make PostController --model=App\Post

App\Admin\Controllers\PostController created successfully.

然后打开app/Admin/Controllers/PostController.php, 就可以看到这个命令生成的代码了.

如果加上参数--output或者-O, 将会打印出代码,而不会创建控制器文件。

 类似资料: