Commands

# Install

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 performing migrations.

For more detailed information, please refer to the section Installation .

# Apply

The command to create the apply class is:

php artisan moonshine:apply

After executing the command, a file will be created in the app/MoonShine/Applies directory. The created class must be registered with the service provider.

# Component

The 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 Blade file in the resources/views/admin/components directory.

For more detailed information, please refer to the section Components .

# Controller

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. Which can be used in admin panel routes.

For more detailed information, please refer to the section Controllers .

# Field

The 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 Blade file in the directory /resources/views/admin/fields.

For more detailed information, please refer to the section Fields .

# Handler

The command creates a Handler class for its import and export implementations:

php artisan moonshine:handler

After executing the command, the handler class will be created in the directory app/MoonShine/Handlers.

For more detailed information, please refer to the section Import/Export .

# Page

The command creates a page for the admin panel:

php artisan moonshine:page

Available options:

  • --crud - creates a group of pages: index, detail and form page;
  • --dir= - the directory in which the files will be located relative to app/MoonShine, default Page;
  • --extends= - a class that the page will extend, for example IndexPage, FormPage or DetailPage.

After executing the command, a default page (or group of pages) will be created in the directory app/MoonShine/Pages.

For more detailed information, please refer to the section Page .

# Policy

The command creates a Policy bound 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 detailed information, please refer to the section Authorization .

# Resource

Command to create resources:

php artisan moonshine:resource

Available options:

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

There are several options available when creating a Resource:

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 directory app/MoonShine/Pages.

For more detailed information, please refer to the section Models Resources .

# Type Cast

The 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 detailed information, please refer to the section TypeCasts .

# User

The command that allows you to create a super user:

php artisan moonshine:user

Available options:

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

# Publish

Posting team:

php artisan moonshine:publish

There are several options available for publishing:

  • Assets - MoonShine admin panel assets;
  • Layout - MoonShineLayout class, responsible for the general appearance of the admin panel;
  • System Resources - system MoonShineUserResource, MoonShineUserRoleResource, which you can change.