Use Decorations to improve field and interface appearance in MoonShine
fields or filters methods of a resource class.website·Indexed 33 days ago
https://moonshine.cutcode.devDocumentation for MoonShine, covering components such as Paginations, Tables, Cards, and Modals, as well as filters like SelectFilter and SwitchFilter, and fields including MorphMany and StackFields. This version is an older release; users are encouraged to upgrade to MoonShine 2.x.
fields or filters methods of a resource class.MoonShine allows developers to extend its core functionality by creating custom packages or extending specific entities. The following entities are available for extension:
For developers creating a new package, MoonShine provides an official package template: https://github.com/moonshine-software/moonshine-package-template
MoonShine allows developers to extend basic functionality or create custom packages. The following entities are available for extension:
For those creating a new package, a ready-made template is available on GitHub.
# Package template available at:
https://github.com/moonshine-software/moonshine-package-templatecolumnSpan, to control their positioning and width within the grid.MoonShine allows developers to extend its core functionality by creating custom implementations of specific entities. This is useful for building custom packages or adding specialized behavior to the admin panel. The following entities can be extended:
fields or filters methods of a resource.The HasOne field is used for Laravel relationships of type hasOne. It allows creating a new record in the related table and linking it to the current record. If a relationship already exists, the existing record is edited.
When defining the nested fields within the fields() method of a HasOne component, including the ID field is mandatory.
If the nested fields are too numerous to be displayed comfortably in the default inline view, use the fullPage() method to render them in a standard full-page layout. Additionally, resourceMode is available for advanced configuration (refer to HasMany documentation for details).
use MoonShine extbf{Fields}\{HasOne, ID, Text"};
// Inside your resource class
public function fields(): array
{
return [
HasOne::make('City', 'city', 'name')
->fields([
ID::make(), // Required
Text::make('Value', 'name'),
])
->fullPage(), // Optional: renders fields in a full-page view instead of inline
];
}composer require moonshine/quilluse MoonShine
Quill
Fields
Quill;
return [
Quill::make('Description', 'description'),
];BelongsToMany relationship, use the fields() method on the BelongsToMany field instance.use MoonShine
Fields
BelongsToMany;
use MoonShine
Fields
Text;
public function fields(): array
{
return [
BelongsToMany::make('Contacts', 'contacts', 'name')
->fields([
Text::make('Contact', 'text'),
])
];
}NoInput field is used to display text data from a model or generate custom text that should not be editable by the user. It is strictly for data presentation, not for input or amendment.use MoonShine\Fields\NoInput;
public function fields(): array
{
return [
NoInput::make('No input field', 'no_input', static fn() => fake()->realText()),
];
}MoonShineServiceProvider using the MoonShine singleton. You can register them as general resources or specifically as menu items to make them visible in the navigation sidebar.namespace App\Providers;
use App\MoonShine\Resources\PostResource;
use Illuminate\Support\ServiceProvider;
use MoonShine\Menu\MenuItem;
use MoonShine\MoonShine;
class MoonShineServiceProvider extends ServiceProvider
{
public function boot()
{
// Register resources in the system
app(MoonShine::class)->resources([
new PostResource(),
]);
// Register resources in the navigation menu
app(MoonShine::class)->menu([
MenuItem::make('Posts', new PostResource()),
]);
}
}ExamplePage) has been generated via the CLI, instantiate the class and pass it as the second argument to MenuItem::make() to include it in the MoonShine menu.use Illuminate\Support\ServiceProvider;
use MoonShine\Menu\MenuItem;
use MoonShine\MoonShine;
use MoonShine\Pages\ExamplePage;
class MoonShineServiceProvider extends ServiceProvider
{
public function boot(): void
{
app(MoonShine::class)->menu([
MenuItem::make('Example', new ExamplePage())
]);
}
}