Advanced

Commands

Use the space key to select the appropriate item.

Installation

Command to install the MoonShine package in your Laravel project:

php artisan moonshine:install

Available options:

  • -u, --without-user - without creating a super user,
  • -m, --without-migrations - without running migrations,
  • -l, --default-layout - select the default template (without prompting for a compact theme),
  • -a, --without-auth - without authentication,
  • -d, --without-notifications - without notifications,

For more details, refer to the Installation section.

User

Command to create a super user:

php artisan moonshine:user

Available options:

  • --u|username= - user login/email,
  • --N|name= - user name,
  • --p|password= - password.

Resource

Command to create resources:

php artisan moonshine:resource

Available options:

  • --m|model= - Eloquent model for the resource model,
  • --t|title= - section title,
  • --test or --pest - additionally generate a test class.

When creating a Resource, several options are available:

After executing the command, a resource file will be created in the app/MoonShine/Resources/ directory. If a model resource with pages is created, additional pages will be created in the app/MoonShine/Pages directory.

For more details, refer to the Model Resources section.

Page

Command creates a page for the admin panel:

php artisan moonshine:page
  • --crud - creates a group of pages: index, detail, and form,
  • --without-register - without automatic registration in the provider,
  • --dir= - directory where the files will be located relative to app/MoonShine, defaults to Page,
  • --extends= - class that the page will extend, e.g., IndexPage, FormPage, or DetailPage.

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 creates a template for the admin panel:

php artisan moonshine:layout
  • --compact - inherits the compact theme,
  • --full - inherits the base theme,
  • --default - set as the default template in the config
  • --dir= - directory where the files will be located relative to app/MoonShine, defaults to Layouts.

After executing the command, a template will be created in the app/MoonShine/Layouts directory.

For more details, refer to the Layout section.

Component

Command creates a custom component:

php artisan moonshine:component

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 Layout section.

Field

Command allows you to create a custom field:

php artisan moonshine:field

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:controller

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 creates a Handler class:

php artisan moonshine:handler

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 creates a Policy tied to the admin panel user:

php artisan moonshine:policy

After executing the command, a class will be created in the app/Policies directory.

For more details, refer to the Authorization section.

Type Casting

Command creates a TypeCast class for working with data:

php artisan moonshine:type-cast

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: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 assets

Available types:

  • assets
  • assets-template
  • resources
  • forms
  • pages

Apply

Command for creating an apply class:

php artisan moonshine:apply

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.