Use the space key to select the appropriate item.
Installation
Command to install the MoonShine package in your Laravel project:
php artisan moonshine:installphp artisan moonshine:install
Signature:
moonshine:install {--u|without-user} {--m|without-migrations} {--l|default-layout} {--a|without-auth} {--d|without-notifications} {--t|tests-mode} {--Q|quick-mode}moonshine:install {--u|without-user} {--m|without-migrations} {--l|default-layout} {--a|without-auth} {--d|without-notifications} {--t|tests-mode} {--Q|quick-mode}
Available options:
--u|without-user- without creating a superuser,--m|without-migrations- without running migrations,--l|default-layout- select the default template,--a|without-auth- without authentication,--d|without-notifications- without notifications,--t|tests-mode- test mode,--Q|quick-mode- "quick" mode (skipping all dialogs using default settings).
For more details, refer to the Installation section.
User
Command to create a superuser:
php artisan moonshine:userphp artisan moonshine:user
Signature:
moonshine:user {--u|username=} {--N|name=} {--p|password=}moonshine:user {--u|username=} {--N|name=} {--p|password=}
Available options:
--u|username=- user login/email,--N|name=- user name,--p|password=- password.
Resource
Command to create resources:
php artisan moonshine:resourcephp artisan moonshine:resource
Signature:
moonshine:resource {className?} {--type=} {--m|model=} {--t|title=} {--test} {--pest} {--force} {--p|policy} {--base-dir=} {--base-namespace=}moonshine:resource {className?} {--type=} {--m|model=} {--t|title=} {--test} {--pest} {--force} {--p|policy} {--base-dir=} {--base-namespace=}
Available options:
--type=- quick selection of resource type (1 - ModelResource (default), 2 - CrudResource, 3 - Blank Resource),--m|model=- Eloquent model forModelResource,--t|title=- section title,--testor--pest- additionally generate a test class,--force- overwrite the resource without additional confirmation if it already exists,--p|policy- also create Policy,--base-dir=, --base-namespace=- change the base directory and namespace of the class.
When creating a resource, several options are available:
- ModelResource - Standard resource for managing Eloquent models,
- CrudResource - Resource without dependence on Eloquent,
- Blank Resource - empty resource for custom implementations.
After the command is executed, a resource file with CRUD pages is created.
Examples:
php artisan moonshine:resource Post --model=CustomPost --title="Articles"php artisan moonshine:resource Post --model="App\Models\CustomPost"php artisan moonshine:resource Post --model=CustomPost --title="Articles"php artisan moonshine:resource Post --model="App\Models\CustomPost"
For more details, refer to the ModelResource section.
Page
Command to create pages:
php artisan moonshine:pagephp artisan moonshine:page
Signature:
moonshine:page {className?} {--force} {--without-register} {--skip-menu} {--crud} {--dir=} {--extends=} {--base-dir=} {--base-namespace=} {--resource=}moonshine:page {className?} {--force} {--without-register} {--skip-menu} {--crud} {--dir=} {--extends=} {--base-dir=} {--base-namespace=} {--resource=}
Available options:
--force- don't ask for the page type,--without-register- without automatic registration in the provider,--skip-menu- do not add this page to the menu when using autoload menu,--crud- creates a group of pages: index, detail, and form,--dir=- directory where the files will be located relative toapp/MoonShine, defaults to Page,--extends=- class that the page will extend, e.g.,IndexPage,FormPage, orDetailPage,--base-dir=, --base-namespace=- change the base directory and namespace of the class,--resource=- resource, for which pages are created, on the defaultModelResource.
After executing the command, a default page (or group of pages) will be created in the app/MoonShine/Pages directory.
For more details, refer to the Page section.
Layout
Command to create a layout:
php artisan moonshine:layoutphp artisan moonshine:layout
Signature:
moonshine:layout {className?} {--default} {--palette=} {--dir=} {--base-dir=} {--base-namespace=}moonshine:layout {className?} {--default} {--palette=} {--dir=} {--base-dir=} {--base-namespace=}
Available options:
--default- set as the default template in the config,--palette=- preselect a palette class for the layout (uses the global config value if omitted),--dir=- directory where the files will be located relative toapp/MoonShine, defaults toLayouts,--base-dir=, --base-namespace=- change the base directory and namespace of the class.
For more details, refer to the Layout section.
Component
Command to create a custom component:
php artisan moonshine:componentphp artisan moonshine:component
Signature:
moonshine:component {className?} {--base-dir=} {--base-namespace=}moonshine:component {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
After executing the command, a class for the component will be created in the app/MoonShine/Components directory,
and a Blade file will be created in the resources/views/admin/components directory.
For more details, refer to the Components section.
Field
Command to create a custom field:
php artisan moonshine:fieldphp artisan moonshine:field
Signature:
moonshine:field {className?} {--base-dir=} {--base-namespace=}moonshine:field {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
When executing the command, you can specify whether the field will extend the base class or another field.
After executing the command, a field class will be created in the app/MoonShine/Fields directory,
and a Blade file will be created in the /resources/views/admin/fields directory.
For more details, refer to the Field section.
Command to create a controller:
php artisan moonshine:controllerphp artisan moonshine:controller
Signature:
moonshine:controller {className?} {--base-dir=} {--base-namespace=}moonshine:controller {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
After executing the command, a controller class will be created in the app/MoonShine/Controllers directory that can be used in the admin panel routes.
For more details, refer to the Controllers section.
Handler
Command to create a Handler class:
php artisan moonshine:handlerphp artisan moonshine:handler
Signature:
moonshine:handler {className?} {--base-dir=} {--base-namespace=}moonshine:handler {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
After executing the command, a handler class will be created in the app/MoonShine/Handlers directory.
For more details, refer to the Handlers section.
Policy
Command to create a Policy class tied to the admin panel user:
php artisan moonshine:policyphp artisan moonshine:policy
After executing the command, a class will be created in the app/Policies directory.
For more details, refer to the Security > Authorization section.
Type Casting
Command to create a TypeCast class for working with data:
php artisan moonshine:type-castphp artisan moonshine:type-cast
Signature:
moonshine:type-cast {className?} {--base-dir=} {--base-namespace=}moonshine:type-cast {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
After executing the command, a file will be created in the app/MoonShine/TypeCasts directory.
For more details, refer to the TypeCasts section.
Publishing
Command for publishing:
php artisan moonshine:publishphp artisan moonshine:publish
Several options are available for publishing:
- Assets - assets for the MoonShine admin panel,
- Assets template - creates a template for adding custom styles or creating a custom theme for MoonShine,
- System Resources - system
MoonShineUserResource,MoonShineUserRoleResource, which you can modify, - System Forms - system
LoginForm,FiltersForm, which you can modify, - System Pages - system
ProfilePage,LoginPage,ErrorPage, which you can modify.
You can specify the publication type directly in the command.
php artisan moonshine:publish assetsphp artisan moonshine:publish assets
Available types:
- assets
- assets-template
- resources
- forms
- pages
Apply
Command to create an apply class:
php artisan moonshine:applyphp artisan moonshine:apply
Signature:
moonshine:apply {className?} {--base-dir=} {--base-namespace=}moonshine:apply {className?} {--base-dir=} {--base-namespace=}
Available options:
--base-dir=, --base-namespace=- change the base directory and namespace of the class.
After executing the command, a file will be created in the app/MoonShine/Applies directory.
The created class needs to be registered in the service provider.
For more details, refer to the Fields section.