天天看點

Laravel-admin 控制台指令

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

, 将會列印出代碼,而不會建立控制器檔案。