diff --git a/app/Providers/MoonShineServiceProvider.php b/app/Providers/MoonShineServiceProvider.php index 3783a0a3..bbaa885a 100644 --- a/app/Providers/MoonShineServiceProvider.php +++ b/app/Providers/MoonShineServiceProvider.php @@ -35,7 +35,7 @@ protected function menu(): array foreach ($items as $item) { if (!is_string($item)) { $pages[] = DocSection::make( - $item['label'], + $item['title'] ?? $item['label'], $item['slug'], ); } @@ -63,7 +63,7 @@ protected function menu(): array $inner[] = MenuDivider::make($titleDivider); } else { $page = DocSection::make( - $item['label'], + $item['title'] ?? $item['label'], $item['slug'], )->setResource($resources[$slug]); diff --git a/config/menu.php b/config/menu.php index fd1d6c88..ad634b66 100644 --- a/config/menu.php +++ b/config/menu.php @@ -19,20 +19,30 @@ ['slug' => 'page-instance', 'label' => 'Make instance'], ], + 'Components:rectangle-group' => [ + ['slug' => 'components-index', 'label' => 'Basics'], + + // Decorations + 'Decorations:_divider_', + ['slug' => 'components-decoration_tabs', 'label' => 'Tabs', 'title' => 'Decoration Tabs'], + ['slug' => 'components-decoration_heading', 'label' => 'Heading', 'title' => 'Decoration Heading'], + ['slug' => 'components-decoration_block', 'label' => 'Block', 'title' => 'Decoration Block'], + ['slug' => 'components-decoration_layout', 'label' => 'Layout', 'title' => 'Decoration Layout'], + ['slug' => 'components-decoration_collapse', 'label' => 'Collapse', 'title' => 'Decoration Collapse'], + ['slug' => 'components-decoration_divider', 'label' => 'Divider', 'title' => 'Decoration Divider'], + + // Metrics + 'Metrics:_divider_', + ['slug' => 'components-metric_donut_chart', 'label' => 'Donut Chart', 'title' => 'Metric Donut Chart'], + ['slug' => 'components-metric_line_chart', 'label' => 'Line Chart', 'title' => 'Metric Line Chart'], + ['slug' => 'components-metric_value', 'label' => 'Value', 'title' => 'Metric Value'], + ], + 'Appearance:photo' => [ ['slug' => 'appearance-index', 'label' => 'Basics'], ['slug' => 'appearance-layout_builder', 'label' => 'LayoutBuilder'], ['slug' => 'appearance-assets', 'label' => 'AssetsManager'], ['slug' => 'appearance-icons', 'label' => 'Icons'], - - // Text - 'Decorations:_divider_', - ['slug' => 'appearance-decorations_tabs', 'label' => 'Tabs'], - ['slug' => 'appearance-decorations_heading', 'label' => 'Heading'], - ['slug' => 'appearance-decorations_block', 'label' => 'Block'], - ['slug' => 'appearance-decorations_layout', 'label' => 'Layout'], - ['slug' => 'appearance-decorations_collapse', 'label' => 'Collapse'], - ['slug' => 'appearance-decorations_divider', 'label' => 'Divider'], ], 'Models Resources:document-duplicate' => [ @@ -48,6 +58,10 @@ ['slug' => 'resources-metrics', 'label' => 'Metrics'], ['slug' => 'resources-events', 'label' => 'Events'], ['slug' => 'resources-authorization', 'label' => 'Authorization'], + +// ['slug' => 'resources-export', 'label' => 'Export'], +// ['slug' => 'resources-import', 'label' => 'Import'], + // ['slug' => 'resources-actions', 'label' => 'Actions'], // ['slug' => 'resources-active_actions', 'label' => 'Active actions'], // ['slug' => 'resources-item_actions', 'label' => 'Item actions'], @@ -61,22 +75,6 @@ ['slug' => 'menu', 'label' => 'Menu'], ], - 'Appearance:photo' => [ - ['slug' => 'appearance-index', 'label' => 'Basics'], - ['slug' => 'appearance-layout_builder', 'label' => 'LayoutBuilder'], - ['slug' => 'appearance-assets', 'label' => 'AssetsManager'], - ['slug' => 'appearance-icons', 'label' => 'Icons'], - - // Decorations - 'Decorations:_divider_', - ['slug' => 'appearance-decorations_tabs', 'label' => 'Tabs'], - ['slug' => 'appearance-decorations_heading', 'label' => 'Heading'], - ['slug' => 'appearance-decorations_block', 'label' => 'Block'], - ['slug' => 'appearance-decorations_layout', 'label' => 'Layout'], - ['slug' => 'appearance-decorations_collapse', 'label' => 'Collapse'], - ['slug' => 'appearance-decorations_divider', 'label' => 'Divider'], - ], - 'Fields:table-cells' => [ ['slug' => 'fields-index', 'label' => 'Basics'], // Text @@ -149,32 +147,8 @@ ['slug' => 'action_button', 'label' => 'ActionButton'], ], -// 'Decorations:rocket-launch' => [ -// ['slug' => 'decorations-index', 'label' => 'Basics'], -// ['slug' => 'decorations-tabs', 'label' => 'Tabs'], -// ['slug' => 'decorations-heading', 'label' => 'Heading'], -// ['slug' => 'decorations-block', 'label' => 'Block'], -// ['slug' => 'decorations-layout', 'label' => 'Layout', 'badge' => 'new'], -// ['slug' => 'decorations-button', 'label' => 'Button'], -// ['slug' => 'decorations-collapse', 'label' => 'Collapse'], -// ['slug' => 'decorations-divider', 'label' => 'Divider', 'badge' => 'new'], -// ], - -// 'Metrics:chart-bar' => [ -// ['slug' => 'metrics-index', 'label' => 'Basics'], -// ['slug' => 'metrics-value', 'label' => 'Value'], -// ['slug' => 'metrics-line_chart', 'label' => 'Line Chart'], -// ['slug' => 'metrics-donut_chart', 'label' => 'Donut Chart', 'badge' => 'new'], -// ], - -// 'Actions:hand-raised' => [ -// ['slug' => 'actions-index', 'label' => 'Basics'], -// ['slug' => 'actions-export', 'label' => 'Export'], -// ['slug' => 'actions-import', 'label' => 'Import'], -// ], - 'Advanced:moon' => [ - //['slug' => 'advanced-resource', 'label' => 'Resource'], + ['slug' => 'advanced-resource', 'label' => 'Resource'], ['slug' => 'advanced-controller', 'label' => 'Controllers'], ['slug' => 'advanced-form_builder', 'label' => 'FormBuilder'], ['slug' => 'advanced-table_builder', 'label' => 'TableBuilder'], @@ -192,35 +166,35 @@ ':_divider_', 'UI components:code-bracket-square' => [ - ['slug' => 'components-index', 'label' => 'Basics'], - ['slug' => 'components-alert', 'label' => 'Alert'], - ['slug' => 'components-badge', 'label' => 'Badge'], - ['slug' => 'components-boolean', 'label' => 'Boolean'], - ['slug' => 'components-box', 'label' => 'Box'], - ['slug' => 'components-breadcrumbs', 'label' => 'Breadcrumbs'], - ['slug' => 'components-card', 'label' => 'Card'], - ['slug' => 'components-collapse', 'label' => 'Collapse'], - ['slug' => 'components-divider', 'label' => 'Divider'], - ['slug' => 'components-dropdown', 'label' => 'Dropdown'], - ['slug' => 'components-icon', 'label' => 'Icon'], - ['slug' => 'components-files', 'label' => 'Files'], - ['slug' => 'components-form', 'label' => 'Form elements'], - ['slug' => 'components-grid', 'label' => 'Grid/Column'], - ['slug' => 'components-link', 'label' => 'Link'], - ['slug' => 'components-loader', 'label' => 'Loader'], - ['slug' => 'components-modal', 'label' => 'Modal'], - ['slug' => 'components-offcanvas', 'label' => 'Offcanvas'], - ['slug' => 'components-paginations', 'label' => 'Paginations'], - ['slug' => 'components-popover', 'label' => 'Popover'], - ['slug' => 'components-progress_bar', 'label' => 'Progress bar'], - ['slug' => 'components-rating', 'label' => 'Rating'], - ['slug' => 'components-spinner', 'label' => 'Spinner'], - ['slug' => 'components-table', 'label' => 'Table'], - ['slug' => 'components-tabs', 'label' => 'Tabs'], - ['slug' => 'components-thumbnail', 'label' => 'Thumbnail'], - ['slug' => 'components-title', 'label' => 'Title'], - ['slug' => 'components-toast', 'label' => 'Toast'], - ['slug' => 'components-tooltip', 'label' => 'Tooltip'], + ['slug' => 'ui-index', 'label' => 'Basics'], + ['slug' => 'ui-alert', 'label' => 'Alert'], + ['slug' => 'ui-badge', 'label' => 'Badge'], + ['slug' => 'ui-boolean', 'label' => 'Boolean'], + ['slug' => 'ui-box', 'label' => 'Box'], + ['slug' => 'ui-breadcrumbs', 'label' => 'Breadcrumbs'], + ['slug' => 'ui-card', 'label' => 'Card'], + ['slug' => 'ui-collapse', 'label' => 'Collapse'], + ['slug' => 'ui-divider', 'label' => 'Divider'], + ['slug' => 'ui-dropdown', 'label' => 'Dropdown'], + ['slug' => 'ui-icon', 'label' => 'Icon'], + ['slug' => 'ui-files', 'label' => 'Files'], + ['slug' => 'ui-form', 'label' => 'Form elements'], + ['slug' => 'ui-grid', 'label' => 'Grid/Column'], + ['slug' => 'ui-link', 'label' => 'Link'], + ['slug' => 'ui-loader', 'label' => 'Loader'], + ['slug' => 'ui-modal', 'label' => 'Modal'], + ['slug' => 'ui-offcanvas', 'label' => 'Offcanvas'], + ['slug' => 'ui-paginations', 'label' => 'Paginations'], + ['slug' => 'ui-popover', 'label' => 'Popover'], + ['slug' => 'ui-progress_bar', 'label' => 'Progress bar'], + ['slug' => 'ui-rating', 'label' => 'Rating'], + ['slug' => 'ui-spinner', 'label' => 'Spinner'], + ['slug' => 'ui-table', 'label' => 'Table'], + ['slug' => 'ui-tabs', 'label' => 'Tabs'], + ['slug' => 'ui-thumbnail', 'label' => 'Thumbnail'], + ['slug' => 'ui-title', 'label' => 'Title'], + ['slug' => 'ui-toast', 'label' => 'Toast'], + ['slug' => 'ui-tooltip', 'label' => 'Tooltip'], ], // ':_divider_', diff --git a/public/screenshots/metrics_donut_chart.png b/public/screenshots/donut_chart_metric.png similarity index 100% rename from public/screenshots/metrics_donut_chart.png rename to public/screenshots/donut_chart_metric.png diff --git a/public/screenshots/donut_chart_metric_column_span.png b/public/screenshots/donut_chart_metric_column_span.png new file mode 100644 index 00000000..c7c6b6ed Binary files /dev/null and b/public/screenshots/donut_chart_metric_column_span.png differ diff --git a/public/screenshots/donut_chart_metric_column_span_dark.png b/public/screenshots/donut_chart_metric_column_span_dark.png new file mode 100644 index 00000000..94be8454 Binary files /dev/null and b/public/screenshots/donut_chart_metric_column_span_dark.png differ diff --git a/public/screenshots/metrics_donut_chart_dark.png b/public/screenshots/donut_chart_metric_dark.png similarity index 100% rename from public/screenshots/metrics_donut_chart_dark.png rename to public/screenshots/donut_chart_metric_dark.png diff --git a/public/screenshots/metrics_line_chart.png b/public/screenshots/line_chart_metric.png similarity index 100% rename from public/screenshots/metrics_line_chart.png rename to public/screenshots/line_chart_metric.png diff --git a/public/screenshots/line_chart_metric_column_span.png b/public/screenshots/line_chart_metric_column_span.png new file mode 100644 index 00000000..fb10940f Binary files /dev/null and b/public/screenshots/line_chart_metric_column_span.png differ diff --git a/public/screenshots/line_chart_metric_column_span_dark.png b/public/screenshots/line_chart_metric_column_span_dark.png new file mode 100644 index 00000000..19baa246 Binary files /dev/null and b/public/screenshots/line_chart_metric_column_span_dark.png differ diff --git a/public/screenshots/metrics_line_chart_dark.png b/public/screenshots/line_chart_metric_dark.png similarity index 100% rename from public/screenshots/metrics_line_chart_dark.png rename to public/screenshots/line_chart_metric_dark.png diff --git a/public/screenshots/metrics_value.png b/public/screenshots/metrics_value.png deleted file mode 100644 index 40107668..00000000 Binary files a/public/screenshots/metrics_value.png and /dev/null differ diff --git a/public/screenshots/metrics_value_dark.png b/public/screenshots/metrics_value_dark.png deleted file mode 100644 index cea10e7c..00000000 Binary files a/public/screenshots/metrics_value_dark.png and /dev/null differ diff --git a/public/screenshots/metrics_value_format.png b/public/screenshots/metrics_value_format.png deleted file mode 100644 index a814f4d8..00000000 Binary files a/public/screenshots/metrics_value_format.png and /dev/null differ diff --git a/public/screenshots/metrics_value_format_dark.png b/public/screenshots/metrics_value_format_dark.png deleted file mode 100644 index 6cba1208..00000000 Binary files a/public/screenshots/metrics_value_format_dark.png and /dev/null differ diff --git a/public/screenshots/metrics_value_progress.png b/public/screenshots/metrics_value_progress.png deleted file mode 100644 index 11a5c19e..00000000 Binary files a/public/screenshots/metrics_value_progress.png and /dev/null differ diff --git a/public/screenshots/metrics_value_progress_dark.png b/public/screenshots/metrics_value_progress_dark.png deleted file mode 100644 index 9f9d5776..00000000 Binary files a/public/screenshots/metrics_value_progress_dark.png and /dev/null differ diff --git a/public/screenshots/value_metric.png b/public/screenshots/value_metric.png new file mode 100644 index 00000000..3720536b Binary files /dev/null and b/public/screenshots/value_metric.png differ diff --git a/public/screenshots/value_metric_column_span.png b/public/screenshots/value_metric_column_span.png new file mode 100644 index 00000000..dbd66053 Binary files /dev/null and b/public/screenshots/value_metric_column_span.png differ diff --git a/public/screenshots/value_metric_column_span_dark.png b/public/screenshots/value_metric_column_span_dark.png new file mode 100644 index 00000000..5f868c02 Binary files /dev/null and b/public/screenshots/value_metric_column_span_dark.png differ diff --git a/public/screenshots/value_metric_dark.png b/public/screenshots/value_metric_dark.png new file mode 100644 index 00000000..42385b2c Binary files /dev/null and b/public/screenshots/value_metric_dark.png differ diff --git a/public/screenshots/value_metric_format.png b/public/screenshots/value_metric_format.png new file mode 100644 index 00000000..bd37491c Binary files /dev/null and b/public/screenshots/value_metric_format.png differ diff --git a/public/screenshots/value_metric_format_dark.png b/public/screenshots/value_metric_format_dark.png new file mode 100644 index 00000000..891ed0df Binary files /dev/null and b/public/screenshots/value_metric_format_dark.png differ diff --git a/public/screenshots/value_metric_icon.png b/public/screenshots/value_metric_icon.png new file mode 100644 index 00000000..b640d8e7 Binary files /dev/null and b/public/screenshots/value_metric_icon.png differ diff --git a/public/screenshots/value_metric_icon_dark.png b/public/screenshots/value_metric_icon_dark.png new file mode 100644 index 00000000..fab07169 Binary files /dev/null and b/public/screenshots/value_metric_icon_dark.png differ diff --git a/public/screenshots/value_metric_progress.png b/public/screenshots/value_metric_progress.png new file mode 100644 index 00000000..fcc9041f Binary files /dev/null and b/public/screenshots/value_metric_progress.png differ diff --git a/public/screenshots/value_metric_progress_dark.png b/public/screenshots/value_metric_progress_dark.png new file mode 100644 index 00000000..3015cb87 Binary files /dev/null and b/public/screenshots/value_metric_progress_dark.png differ diff --git a/resources/views/pages/en/actions/export.blade.php b/resources/views/pages/en/actions/export.blade.php deleted file mode 100644 index c5441f0a..00000000 --- a/resources/views/pages/en/actions/export.blade.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - Exports all data considering filters - - - -use MoonShine\Actions\ExportAction; - -//... -public function actions(): array -{ - return [ - ExportAction::make('Export') - // Optional methods - // If you want to run in the background - ->queue() - // Selecting a drive - ->disk('public') - // Selecting a save directory - ->dir('/exports') - // If you want to use csv format - ->csv() - // If you use csv - ->delimiter(',') - , - ]; -} -//... - - - - Only fields having a showOnExport flag will be exported - - - - -//... -public function fields(): array -{ - return [ - ID::make()->showOnExport(), - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/actions/import.blade.php b/resources/views/pages/en/actions/import.blade.php deleted file mode 100644 index 5506cd44..00000000 --- a/resources/views/pages/en/actions/import.blade.php +++ /dev/null @@ -1,53 +0,0 @@ - - - - Imports data - - - -use MoonShine\Actions\ImportAction; - -//... -public function actions(): array -{ - return [ - ImportAction::make('Import') - // Optional methods - // If you want to run in the background - ->queue() - // Selecting a drive - ->disk('public') - // Selecting a save directory - ->dir('/exports') - // Delete after importing - ->deleteAfter() - // If you use csv - ->delimiter(',') - , - ]; -} -//... - - - - Only those fields will be imported that are marked using the useOnImport - - - - -//... -public function fields(): array -{ - return [ - // Be sure to mark the identifier, otherwise all entries will be added and not edited - ID::make() - ->useOnImport(), - - Text::make('Title') - ->useOnImport(), - ]; -} -//... - - - diff --git a/resources/views/pages/en/actions/index.blade.php b/resources/views/pages/en/actions/index.blade.php deleted file mode 100644 index d38f10dd..00000000 --- a/resources/views/pages/en/actions/index.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - - The actions are set in the actions resource method. - - - - Could be used to append additional processes for the main page of the resource. - - - diff --git a/resources/views/pages/en/advanced/assets.blade.php b/resources/views/pages/en/advanced/assets.blade.php deleted file mode 100644 index abcce6ea..00000000 --- a/resources/views/pages/en/advanced/assets.blade.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - MoonShine can include any of your css and js files by adding them to the - MoonShineServiceProvider - - - -use MoonShine\Utilities\AssetManager; - -class MoonShineServiceProvider extends ServiceProvider -{ - //... - public function boot(): void - { - //... - app(AssetManager::class)->add([ - '/css/style.css', - '/js/main.js', - ]); - //... - } - //... -} - - - - - - diff --git a/resources/views/pages/en/advanced/authentication.blade.php b/resources/views/pages/en/advanced/authentication.blade.php deleted file mode 100644 index 879bcd8d..00000000 --- a/resources/views/pages/en/advanced/authentication.blade.php +++ /dev/null @@ -1,133 +0,0 @@ - - -Basics - - - The Moonshine admin panel implements an authentication system that is enabled by default, - but if you need to allow access for all users, - you can disable it in the configuration file config/moonshine.php - - - -return [ - // ... - 'auth' => [ - 'enable' => true, // [tl! focus] - // ... - ], - // ... -]; - - - - - -Extending capabilities - - - If you use your own guard, provider, then they can be redefined in the configuration, - as well as the MoonshineUser model - - - -return [ - // ... - 'auth' => [ - // ... - 'guard' => 'moonshine', // [tl! focus:start] - 'guards' => [ - 'moonshine' => [ - 'driver' => 'session', - 'provider' => 'moonshine', - ], - ], - 'providers' => [ - 'moonshine' => [ - 'driver' => 'eloquent', - 'model' => MoonshineUser::class, - ], - ], // [tl! focus:end] - // ... - ], - // ... -]; - - - - If there is a need to add text under the login button (for example, add a registration button), - then this can easily be done through the configuration file - - - -return [ - // ... - 'auth' => [ - // ... - 'footer' => 'CutCode' // [tl! focus] - ], - // ... - ], - // ... -]; - - -Greetings - - - To change the welcome text on the authentication page, - you need to create a language file lang/vendor/moonshine/en/ui.php - - - -return [ - // ... - 'login' => [ // [tl! focus:start] - 'title' => 'Welcome to :moonshine_title!', - 'description' => 'Please sign-in to your account', - ], // [tl! focus:end] - // ... -]; - - -Profile - - - You can override the fields for the profile in the configuration file config/moonshine.php - - - -return [ - // ... - 'auth' => [ - 'enable' => true, - 'fields' => [ // [tl! focus:start] - 'username' => 'email', - 'password' => 'password', - 'name' => 'name', - 'avatar' => 'avatar' - ], // [tl! focus:end] - 'guard' => 'moonshine', - // ... - ], - // ... -]; - - - - If you don't want to use an avatar, - then specify 'avatar'=>'' or 'avatar'=>false. - - - - If you want to change the look of your profile page, - then create a file resources/views/vendor/moonshine/profile.blade.php - - - diff --git a/resources/views/pages/en/advanced/authorization.blade.php b/resources/views/pages/en/advanced/authorization.blade.php deleted file mode 100644 index 4a814012..00000000 --- a/resources/views/pages/en/advanced/authorization.blade.php +++ /dev/null @@ -1,92 +0,0 @@ - - - - We stick to the Laravel concept, so using the Laravel policy we can operate - access rights from the MoonShine admin panel - - - - MoonShine resource controllers check each method for permissions. - If difficulties arise, check the official Laravel documentation - - - - By default, permission checking is disabled for resources. To enable it, you must add the - $withPolicy property - - - - Available Policy methods: - - - - - -namespace App\Policies; - -use Illuminate\Auth\Access\HandlesAuthorization; -use MoonShine\Models\MoonshineUser; -use App\Models\Post; - -class PostPolicy -{ - use HandlesAuthorization; - - public function viewAny(MoonshineUser $user) - { - // - } - - public function view(MoonshineUser $user, Post $model) - { - // - } - - public function create(MoonshineUser $user) - { - // - } - - public function update(MoonshineUser $user, Post $model) - { - // - } - - public function delete(MoonshineUser $user, Post $model) - { - // - } - - public function massDelete(MoonshineUser $user) - { - // - } - - public function restore(MoonshineUser $user, Post $model) - { - // - } - - public function forceDelete(MoonshineUser $user, Post $model) - { - // - } -} - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ -//... - -public static bool $withPolicy = true; // [tl! focus] - -//... -} - - - diff --git a/resources/views/pages/en/advanced/dashboard.blade.php b/resources/views/pages/en/advanced/dashboard.blade.php deleted file mode 100644 index 2d853b1f..00000000 --- a/resources/views/pages/en/advanced/dashboard.blade.php +++ /dev/null @@ -1,115 +0,0 @@ - - -Basics - - The home page of the admin panel can be customized through the class app/MoonShine/Dashboard.php. - - - - Currently you can display metrics in the control panel - - - - The required metrics are registered in the blocks method and placed in the DashboardBlock wrapper for a convenient arrangement of the panel - - - - Layout (columnSpan) - decorating methods are also available for the elements - - - -namespace App\MoonShine; - -use App\Models\User; -use MoonShine\Dashboard\DashboardBlock; -use MoonShine\Dashboard\DashboardScreen; -use MoonShine\Metrics\ValueMetric; - -class Dashboard extends DashboardScreen -{ - public function blocks(): array - { - return [ - DashboardBlock::make([ - ValueMetric::make('Users') - ->value(User::query()->count()) - ]) - ]; - } -} - - - - - -Block with resource records - - - Sometimes it is extremely convenient to add a table with records from a resource to the main page for quick access. - To do this, use ResourcePreview - - - -namespace App\MoonShine; - -use App\Models\Article; -use MoonShine\Dashboard\DashboardBlock; -use MoonShine\Dashboard\DashboardScreen; -use MoonShine\Dashboard\ResourcePreview; - -class Dashboard extends DashboardScreen -{ - public function blocks(): array - { - return [ - DashboardBlock::make([ - ResourcePreview::make( - new ArticleResource(), // Mandatory parameter with MoonShine resource - 'Latest articles' // Optional - block header - Article::query()->where('active', true)->limit(2) // Optional QueryBuilder - ) - ]) - ]; - } -} - - - - - -Text block - - - To display plain text - - - -namespace App\MoonShine; - -use MoonShine\Dashboard\DashboardBlock; -use MoonShine\Dashboard\DashboardScreen;Welcome -use MoonShine\Dashboard\TextBlock; - -class Dashboard extends DashboardScreen -{ - public function blocks(): array - { - return [ - DashboardBlock::make([ - TextBlock::make( - 'Welcome', - view('welcome')->render() - ) - ]) - ]; - } -} - - diff --git a/resources/views/pages/en/advanced/development.blade.php b/resources/views/pages/en/advanced/development.blade.php deleted file mode 100644 index deee2407..00000000 --- a/resources/views/pages/en/advanced/development.blade.php +++ /dev/null @@ -1,122 +0,0 @@ - - - - MoonShine provides opportunities to extend the basic functionality and write your own packages that improve the features. - In this section, we will provide a list of such packages, an example with creating your own field and action. - - - - If you can't figure out how your MoonShine package should look like, we've prepared a ready-made template for you. - - Package template - - - - - The following entities could be extended: - - - -Custom field - - - Here is a small example of creating your own field! - It is a visual editor based on the CKEditor js plugin - - - - First, let's create a class that extends the MoonShine fields - - - -namespace App\MoonShine\Fields; - -use MoonShine\Fields\Field; - -final class CKEditor extends Field -{ - protected static string $view = 'fields.ckeditor'; - - protected array $assets = [ - 'https://cdn.ckeditor.com/ckeditor5/35.3.0/super-build/ckeditor.js' - ]; -} - - - - Then, create a view with implementation - - - - - - That's it! - - -Custom Action - - - MoonShine comes with several built-in actions such as - Export и - Import - but you can also create your own custom actions. - - - - To do this, you need to create a class that extends the MoonShine action class and define the handle method. - - - -namespace App\MoonShine\Actions; - -use MoonShine\Actions\Action; - -class CustomAction extends Action -{ - public function handle(): mixed - { - // Code with the handler logic - } -} - - - - This is enough to display our custom action on the resource page. - However, let's take a look at what else we can define in our action class. - - - -class CustomAction extends Action -{ - protected static string $view = 'view.custom'; // Custom blade mapping - - protected bool $withQuery = true; // Whether to pass the entire current getQuery to the action's URL. - - protected bool $inDropdown = false; // Display the button outside the dropdown menu. - - protected ?string $icon = 'heroicons.outline.table-cells'; // Icon for the button. -} - - - - Next, register the action in the actions method of the resource where you want to display it. - - - -public function actions(): array -{ - return [ - CustomAction::make('Custom Action'), - ]; -} - - - - That's it! - - diff --git a/resources/views/pages/en/advanced/events.blade.php b/resources/views/pages/en/advanced/events.blade.php deleted file mode 100644 index dff96205..00000000 --- a/resources/views/pages/en/advanced/events.blade.php +++ /dev/null @@ -1,57 +0,0 @@ - - - - Since MoonShine is based on standard eloquent methods for adding, editing and deleting, you can easily use standard Laravel events: - - -https://laravel.com/docs/9.x/eloquent#events - - - - But sometimes you need to snap exactly to the events within the MoonShine resources! - To do this, you need to implement the events you want in the resource - - - -protected function beforeCreating(Model $item) -{ - // Event before adding an entry -} - -protected function afterCreated(Model $item) -{ - // Event after adding a record -} - -protected function beforeUpdating(Model $item) -{ - // Event before record update -} - -protected function afterUpdated(Model $item) -{ - // Event after record update -} - -protected function beforeDeleting(Model $item) -{ - // Event before record deletion -} - -protected function afterDeleted(Model $item) -{ - // Event after record deletion -} - -protected function beforeMassDeleting(array $ids) -{ - // Event before mass deletion of records -} - -protected function afterMassDeleted(array $ids) -{ - // Event after mass deletion of records -} - - - diff --git a/resources/views/pages/en/advanced/localization.blade.php b/resources/views/pages/en/advanced/localization.blade.php deleted file mode 100644 index 1cd127cb..00000000 --- a/resources/views/pages/en/advanced/localization.blade.php +++ /dev/null @@ -1,8 +0,0 @@ - - - - After installing MoonShine you will see a folder with MoonShine translations in the translations folder. - Here you can add new languages or modify the current ones. - - - diff --git a/resources/views/pages/en/advanced/menu.blade.php b/resources/views/pages/en/advanced/menu.blade.php deleted file mode 100644 index 5abb0970..00000000 --- a/resources/views/pages/en/advanced/menu.blade.php +++ /dev/null @@ -1,252 +0,0 @@ - - -Registration - - - We have already figured out how to register sections of the admin panel - to make them appear in the menu - - - -namespace App\Providers; - -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; // [tl! focus] -use MoonShine\MoonShine; // [tl! focus] -use MoonShine\Resources\MoonShineUserResource; -use MoonShine\Resources\MoonShineUserRoleResource; - -class MoonShineServiceProvider extends ServiceProvider -{ - //... - - public function boot() - { - app(MoonShine::class)->menu([ // [tl! focus:start] - MenuItem::make('Admins', new MoonShineUserResource()), - MenuItem::make('Roles', new MoonShineUserRoleResource()), - ]); // [tl! focus:end] - } -} - - - - But to make our interface convenient we can also group menu items - - - -namespace App\Providers; - -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; -use MoonShine\Menu\MenuGroup; // [tl! focus] -use MoonShine\MoonShine; -use MoonShine\Resources\MoonShineUserResource; -use MoonShine\Resources\MoonShineUserRoleResource; - -class MoonShineServiceProvider extends ServiceProvider -{ - //... - - public function boot() - { - app(MoonShine::class)->menu([ - MenuGroup::make('System', [ // [tl! focus] - MenuItem::make('Admins', new MoonShineUserResource()), - MenuItem::make('Roles', new MoonShineUserRoleResource()), - ]) // [tl! focus] - ]); - } -} - - - - You just need to add the resources as a second parameter to the MoonShine\Menu\MenuGroup class. - And the first parameter is the name of the group! - - - - - -Condition-based display - - - Displays menu based on the condition - - - -//... -app(MoonShine::class)->menu([ - MenuGroup::make('System', [ - MenuItem::make('Admins', new MoonShineUserResource()), - MenuItem::make('Roles', new MoonShineUserRoleResource()), - ])->canSee(function(Request $request) { // [tl! focus:start] - return $request->user('moonshine')?->id === 1; - }) // [tl! focus:end] -]); -//... - - -External link - - - Adding a custom link - - - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Документация Laravel', 'https://laravel.com') // [tl! focus] -]); -//... - - - - Links can be passed through a function - - - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Admins', function () { // [tl! focus:start] - return (new MoonShineUserResource())->route('index'); - }), - MenuItem::make('Home', fn() => route('home')) // [tl! focus:end] -]); -//... - - -Icon - - - You can also change the icon of the menu item - - - -//... -app(MoonShine::class)->menu([ - MenuGroup::make('Система', [ // [tl! focus:start] - MenuItem::make('Admins', new MoonShineUserResource())->icon('heroicons.hashtag'), - MenuItem::make('Roles', new MoonShineUserRoleResource())->icon('heroicons.hashtag'), - ])->icon('app') // [tl! focus:end] - // or - MenuGroup::make('Blog', [ // [tl! focus:start] - MenuItem::make('Comments', new CommentResource(), 'heroicons.chat-bubble-left') - ], 'heroicons.newspaper') // [tl! focus:end] -]); -//... - - - - For more information, see Icons - - -Tag - - - You can add a counter to the menu item - - - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Comments', new CommentResource()) - ->badge(fn() => Comment::query()->count()), // [tl! focus] -]); -//... - - - - - -Translation - - - To translate menu items, you need to add the translation key as the name - and add the translatable() method - - - -//... -app(MoonShine::class)->menu([ - MenuItem::make('menu.Comments', new CommentResource()) - ->translatable() // [tl! focus] - // or - MenuItem::make('Comments', new CommentResource()) - ->translatable('menu') // [tl! focus] -]); -//... - - - -// lang/ru/menu.php - -return [ - 'Comments' => 'Комментарии', -]; - - - - To translate menu labels, you can use Laravel's translation tools - - - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Comments', new CommentResource()) - ->badge(fn() => __('menu.badge.new')) // [tl! focus] -]); -//... - - -Divider - - - Menu items can be visually separated using MenuDivider - - - -use MoonShine\Menu\MenuDivider; // [tl! focus] - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Categories', new CategoryResource()), - MenuDivider::make(), // [tl! focus] - MenuItem::make('Articles', new ArticleResource()), -]); -//... - - - - - - - You can use text as a separator, for this you need to pass it to the make() method - - - -use MoonShine\Menu\MenuDivider; // [tl! focus] - -//... -app(MoonShine::class)->menu([ - MenuItem::make('Categories', new CategoryResource()), - MenuDivider::make('Divider'), // [tl! focus] - MenuItem::make('Articles', new ArticleResource()), -]); -//... - - - - - - diff --git a/resources/views/pages/en/advanced/notifications.blade.php b/resources/views/pages/en/advanced/notifications.blade.php deleted file mode 100644 index 400286b1..00000000 --- a/resources/views/pages/en/advanced/notifications.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - If you need to add notifications to the MoonShine notification center, - you can use the class: MoonShine\Notifications\MoonShineNotification - - - -use MoonShine\Notifications\MoonShineNotification; - -MoonShineNotification::send( - message: 'Notification message', - // Optional button - button: ['link' => 'https://moonshine.cutcode.dev', 'label' => 'Click me'], - // Optional id administrators (by default for everyone) - ids: [1,2,3], - // Optional icon color (purple, pink, blue, green, yellow, red, gray) - color: 'green' -); - - - - - - diff --git a/resources/views/pages/en/advanced/pages.blade.php b/resources/views/pages/en/advanced/pages.blade.php deleted file mode 100644 index 02712e12..00000000 --- a/resources/views/pages/en/advanced/pages.blade.php +++ /dev/null @@ -1,150 +0,0 @@ - - -Basics - - - You can create your own blank pages based on the blade view - and UI components, - style in your own way, as well as organize some kind of logic. - - - -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; -use MoonShine\MoonShine; -use MoonShine\Resources\CustomPage; // [tl! focus] - -class MoonShineServiceProvider extends ServiceProvider -{ - public function boot(): void - { - app(MoonShine::class)->menu([ - MenuItem::make( - 'Page title', - CustomPage::make('Page title', 'slug', 'view', fn() => []) // [tl! focus] - ) - ]); - } -} - - - - The first argument - page title. - - - - The second argument - page slug to generate url. - - - - The third argument - your custom blade view, which could be found in the resources/views. - - - - The fourth argument - the data required for view. - - - - You can use blade components which have a handler class to add your own logic. - - -Without title - - - Sometimes it is not required to display the title on a custom page, so it can be hidden using the withoutTitle method. - - - -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; -use MoonShine\MoonShine; -use MoonShine\Resources\CustomPage; - -class MoonShineServiceProvider extends ServiceProvider -{ - public function boot(): void - { - app(MoonShine::class)->menu([ - MenuItem::make( - 'Page title', - CustomPage::make('Page title', 'slug', 'view', fn() => []) - ->withoutTitle() // [tl! focus] - ) - ]); - } -} - - -Layout - - - You can use custom layout, for this you need to specify the path to it in the corresponding method. - - - -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; -use MoonShine\MoonShine; -use MoonShine\Resources\CustomPage; - -class MoonShineServiceProvider extends ServiceProvider -{ - public function boot(): void - { - app(MoonShine::class)->menu([ - MenuItem::make( - 'Page title', - CustomPage::make('Page title', 'slug', 'view', fn() => []) - ->layout('path') // [tl! focus] - ) - ]); - } -} - -] -class CustomPage - - - Pages can be created through a class, just run the command: - - - - php artisan moonshine:page ExamplePage - - - - As a result, a ExamplePage class will be created, which will be the basis of the custom page. - It is located by default in the app/MoonShine/Pages directory. - - -When executing the command, you can immediately set an alias, title and blade view for your page. - - - php artisan moonshine:page ExamplePage --alias="example" --title="Example Page" --view="pages.example" - - -After creating a page, it can be added to the menu. - - -use Illuminate\Support\ServiceProvider; -use MoonShine\Pages\ExamplePage; // [tl! focus] - -class MoonShineServiceProvider extends ServiceProvider -{ - public function boot(): void - { - app(MoonShine::class)->menu([ - MenuItem::make('Example', new ExamplePage()) // [tl! focus] - ]); - } -} - - - diff --git a/resources/views/pages/en/advanced/routes.blade.php b/resources/views/pages/en/advanced/routes.blade.php deleted file mode 100644 index 348d4ffa..00000000 --- a/resources/views/pages/en/advanced/routes.blade.php +++ /dev/null @@ -1,68 +0,0 @@ - - -Resource routes - - - In MoonShine, the resource has many routes registered for various actions: - - - -$this->route('index'); // GET|HEAD - list of items -$this->route('create'); // GET|HEAD - create a new item -$this->route('store'); // POST - save a new item -$this->route('edit', $resourceItem); // GET|HEAD - edit an item -$this->route('update', $resourceItem); // PUT|PATCH - save an item -$this->route('destroy', $resourceItem); // DELETE - delete an item -$this->route('show', $resourceItem); // GET|HEAD - view an item -$this->route('query-tag', $queryTag); // GET|HEAD - filtered list of items by query filter / tag -$this->route('update-column', $resourceItem); // PUT - save an item`s field - - -Custom routes - - - Through the resolveRoutes() method, you can add or override default routes. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - // ... - - public function resolveRoutes(): void // [tl! focus:start] - { - parent::resolveRoutes(); - - Route::prefix('resource')->group(function (): void { - Route::get("{$this->uriKey()}/restore/{resourceItem}", function (Post $item) { - $item->restore(); - - return redirect()->back(); - }); - }); - } // [tl! focus:end] - - // ... -} - - - - To access a route outside of a resource, use (new Resource())->route('index'). - - - diff --git a/resources/views/pages/en/advanced/socialite.blade.php b/resources/views/pages/en/advanced/socialite.blade.php deleted file mode 100644 index 1f7167d7..00000000 --- a/resources/views/pages/en/advanced/socialite.blade.php +++ /dev/null @@ -1,36 +0,0 @@ - - - - For convenience, you can link the account to social networks and simplify the authentication process - - - - The process is based on a Laravel package - Socialite - - -Socialite - - - Make sure you have it installed and configured - - - - Next, in the moonshine config config/moonshine.php install the available drivers (you should already have them set up) and the image for the button - - - -return [ - // - 'socialite' => [ - 'github' => '/images/github.png', - 'facebook' => '/images/facebook.svg' - ] - // -]; - - - - If you use your model for authentication, then you need to add the trait HasMoonShineSocialite to it - - - diff --git a/resources/views/pages/en/components/alert.blade.php b/resources/views/pages/en/components/alert.blade.php deleted file mode 100644 index a0180816..00000000 --- a/resources/views/pages/en/components/alert.blade.php +++ /dev/null @@ -1,58 +0,0 @@ - - -Basics - - - If you need a notification on the page, - you can use the moonshine::alert component - - - - -@include("examples/components/alert") - -Notification type - - - You can change the notification type by specifying the component type - - -@include('pages.en.components.shared.type') - - - -@include("examples/components/alert-type") - -Icon - - - The notification has the ability to change the icon, for this you need to pass it to the icon parameter - - - - -@include("examples/components/alert-icon") - - - For more information, see Icons - - -Removing notifications - - - To remove notifications after some time, you must pass the parameter removable - with the value TRUE - - - - -@include("examples/components/alert-removable") - - diff --git a/resources/views/pages/en/components/badge.blade.php b/resources/views/pages/en/components/badge.blade.php deleted file mode 100644 index 034974d8..00000000 --- a/resources/views/pages/en/components/badge.blade.php +++ /dev/null @@ -1,22 +0,0 @@ - - - - If you need to place a badge on a custom page, - you can use the moonshine::badge component - - - - The following badges are available: - - - - - - - - @include("examples/components/badge") - - - - - diff --git a/resources/views/pages/en/components/boolean.blade.php b/resources/views/pages/en/components/boolean.blade.php deleted file mode 100644 index fc1cb2aa..00000000 --- a/resources/views/pages/en/components/boolean.blade.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - A simple moonshine::boolean component allows you to create an indicator TRUE / FALSE - - - - - - - - @include("examples/components/boolean") - - - - - - - - - - @include("examples/components/boolean-false") - - - - - diff --git a/resources/views/pages/en/components/box.blade.php b/resources/views/pages/en/components/box.blade.php deleted file mode 100644 index 16c70d44..00000000 --- a/resources/views/pages/en/components/box.blade.php +++ /dev/null @@ -1,50 +0,0 @@ - -Basics - - - To highlight content, you can use the moonshine::box component - - - - - - - @include("examples/components/box") - - - -Title - - - The title parameter sets the title of the block - - - - - - - @include("examples/components/box-title") - - - -Dark style - - - You can set a dark style for a block by specifying the dark parameter with the value TRUE - - - - - - - @include("examples/components/box-dark") - - - - diff --git a/resources/views/pages/en/components/breadcrumbs.blade.php b/resources/views/pages/en/components/breadcrumbs.blade.php deleted file mode 100644 index a39f5f98..00000000 --- a/resources/views/pages/en/components/breadcrumbs.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - The moonshine::breadcrumbs component is used to create breadcrumbs - - - - - - - - @include("examples/components/breadcrumbs") - - - - - diff --git a/resources/views/pages/en/components/card.blade.php b/resources/views/pages/en/components/card.blade.php deleted file mode 100644 index 51e3ba68..00000000 --- a/resources/views/pages/en/components/card.blade.php +++ /dev/null @@ -1,40 +0,0 @@ - - -Basics - - - To create cards in the admin panel, use the moonshine::card component - - - - - - -
- @include("examples/components/card") -
-
-
- -Overlay view - - - The overlay view is available for the card - - - - - - -
- @include("examples/components/card-overlay") -
-
-
- -
diff --git a/resources/views/pages/en/components/dropdown.blade.php b/resources/views/pages/en/components/dropdown.blade.php deleted file mode 100644 index 11970cf6..00000000 --- a/resources/views/pages/en/components/dropdown.blade.php +++ /dev/null @@ -1,46 +0,0 @@ - -Basics - - - Using the moonshine::dropdown component, you can create dropdown blocks - - - - -@include("examples/components/dropdown") - -Title - - - -@include("examples/components/dropdown-title") - -Footer - - - -@include("examples/components/dropdown-footer") - -Placement - -@include('pages.en.components.shared.placement') - - - -@include("examples/components/dropdown-placement") - - - - For additional location options, see the official documentation - tippy.js - - - - diff --git a/resources/views/pages/en/components/files.blade.php b/resources/views/pages/en/components/files.blade.php deleted file mode 100644 index a7edbc9d..00000000 --- a/resources/views/pages/en/components/files.blade.php +++ /dev/null @@ -1,41 +0,0 @@ - - -Basics - - - To display a list of files, you can use the moonshine::files component. - - - - - - - - @include("examples/components/files") - - - - -No download - - - To disable the ability to download files, the component must - pass the download parameter with the value FALSE. - - - - - - - - @include("examples/components/files-no-download") - - - - - diff --git a/resources/views/pages/en/components/form.blade.php b/resources/views/pages/en/components/form.blade.php deleted file mode 100644 index 1b3d2ae3..00000000 --- a/resources/views/pages/en/components/form.blade.php +++ /dev/null @@ -1,269 +0,0 @@ - - - - Form components are a wrapper for similar html elements, they can be passed all the necessary attributes. - - -Label - - - - - - - @include("examples/components/form/label") - - - - - - If the field is required, then you can pass the required attribute to style the element - - - - - - - - @include("examples/components/form/label-required") - - - - -Input - - - - - - - @include("examples/components/form/input") - - - - -Checkbox - - - - - - - @include("examples/components/form/checkbox") - - - - -Radio - - - - - - - @include("examples/components/form/radio") - - - - -Color select - - - - - - - @include("examples/components/form/color") - - - - -Button - - - - - - - @include("examples/components/form/button") - - - - -Hint - - - - - - - @include("examples/components/form/hint") - - - - -File - - - - - - - @include("examples/components/form/file") - - - - - - Using the component, you can display previously uploaded files. - - - - - - - - @include("examples/components/form/file-files") - - - - - - - Additionally, hidden fields will be created with the values passed in the files[] array. - - - - - You can pass additional parameters to the component: - - - download - download downloaded file
- removable - removal from the list of downloaded files
- imageable - display image previews -
- - - - - - - @include("examples/components/form/file-full") - - - - -Range - - - - - - - @include("examples/components/form/range") - - - - -Select - - - - - or via slot:options - - - - - - - - @include("examples/components/form/select") - - - - - - You can combine values into groups. - - - - - - - - @include("examples/components/form/select-groups") - - - - - - You can pass additional parameters to the component: - - - searchable - search by values
- nullable - can be NULL -
- - - - - - - @include("examples/components/form/select-full") - - - - - - For asynchronous loading of values, you need to specify the url in the asyncRoute attribute, - which will return data in json format - - - - -Switcher - - - - - - - @include("examples/components/form/switcher") - - - - - - onValue - value when active
- offValue - value when inactive -
- -Textarea - - - - - - - @include("examples/components/form/textarea") - - - - -
diff --git a/resources/views/pages/en/components/grid.blade.php b/resources/views/pages/en/components/grid.blade.php deleted file mode 100644 index 7ced2e4c..00000000 --- a/resources/views/pages/en/components/grid.blade.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - You can use moonshine::grid to arrange elements on the page - and moonshine::column components. - - - - The grid consists of 12 columns. - - - - - - - - @include("examples/components/grid") - - - - - - adaptiveColSpan - the number of columns that occupy the block when the screen size is up to 1280 pixels.
- colSpan - the number of columns that occupy a block with a screen size of 1280px. -
- -
diff --git a/resources/views/pages/en/components/icon.blade.php b/resources/views/pages/en/components/icon.blade.php deleted file mode 100644 index aaa4b6ff..00000000 --- a/resources/views/pages/en/components/icon.blade.php +++ /dev/null @@ -1,77 +0,0 @@ - - -Basics - - - To insert icons into your custom elements, - you can use the moonshine::icon component - - - - - - @include("examples/components/icon") - - - - All available icons - - -Size - - - Using the size parameter, you can set the size of the icon. - - - - - - @include("examples/components/icon-size") - - - - The value of the size parameter corresponds to the sizes in tailwindcss - - -Color - - - Using the color parameter, you can set the color of the icon - - - - - - @include("examples/components/icon-color") - - - - Several colors are available by default, but you can expand them using your own - color classes tailwindcss - - -Customization - - - An arbitrary style for icons can be set via the class parameter - - - - - - @include("examples/components/icon-class") - - - - Build MoonShine contains a limited list of tailwindcss classes, - use custom styles - - - diff --git a/resources/views/pages/en/components/index.blade.php b/resources/views/pages/en/components/index.blade.php deleted file mode 100644 index 26fa1212..00000000 --- a/resources/views/pages/en/components/index.blade.php +++ /dev/null @@ -1,15 +0,0 @@ - - - - A lot of UI components are used to create the MoonShine admin panel interface. - - - - You can use these components to build your own templates, custom fields, filters, decorations or pages. - - - - The use of components speeds up development and allows you to maintain a single style of the project. - - - diff --git a/resources/views/pages/en/components/link.blade.php b/resources/views/pages/en/components/link.blade.php deleted file mode 100644 index 5817019a..00000000 --- a/resources/views/pages/en/components/link.blade.php +++ /dev/null @@ -1,58 +0,0 @@ - - -Basics - - - To create a stylized link, you can use the moonshine::link-button - or moonshine::link-native components - - - - - - - - @include("examples/components/link") - - - - -Filled - - - The filled parameter is responsible for filling - - - - - - - - @include("examples/components/link-filled") - - - - -Icon - - - You can pass the parameter icon - - - - - - - - @include("examples/components/link-icon") - - - - - diff --git a/resources/views/pages/en/components/loader.blade.php b/resources/views/pages/en/components/loader.blade.php deleted file mode 100644 index 26d856f8..00000000 --- a/resources/views/pages/en/components/loader.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - The moonshine::loader component allows you to create a stylized loading indicator - - - - - - - - @include("examples/components/loader") - - - - - diff --git a/resources/views/pages/en/components/modal.blade.php b/resources/views/pages/en/components/modal.blade.php deleted file mode 100644 index 948c19d2..00000000 --- a/resources/views/pages/en/components/modal.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - -Basics - - - The moonshine::modal component is used to create modal windows. - - - - -@include("examples/components/modal") - -Wide - - - The wide parameter allows modal windows to take up the entire width. - - - - -@include("examples/components/modal-wide") - - diff --git a/resources/views/pages/en/components/offcanvas.blade.php b/resources/views/pages/en/components/offcanvas.blade.php deleted file mode 100644 index 044a0658..00000000 --- a/resources/views/pages/en/components/offcanvas.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - The moonshine::offcanvas component allows you to create sidebars. - - - - - - - - @include("examples/components/offcanvas") - - - - - diff --git a/resources/views/pages/en/components/paginations.blade.php b/resources/views/pages/en/components/paginations.blade.php deleted file mode 100644 index 566b6fd8..00000000 --- a/resources/views/pages/en/components/paginations.blade.php +++ /dev/null @@ -1,41 +0,0 @@ - - -Basics - - - The moonshine::pagination component allows you to create a stylized page-by-page pagination.
- To do this, add a component to the pagination blade view. -
- - - - - - - @include("examples/components/pagination-mock") - - - - -Simple pagination - - - The simple parameter with the value TRUE allows you to display the pagination in a simplified way. - - - - - - - - @include("examples/components/pagination-mock", ['simple' => true]) - - - - -
diff --git a/resources/views/pages/en/components/popover.blade.php b/resources/views/pages/en/components/popover.blade.php deleted file mode 100644 index 2877159f..00000000 --- a/resources/views/pages/en/components/popover.blade.php +++ /dev/null @@ -1,37 +0,0 @@ - -Basics - - - Using the moonshine::popover component, you can create a popup window - - -@include('pages.ru.components.shared.placement') - - - - - - - @include("examples/components/popover") - - - - -Without use component - - - - - - - @include("examples/components/popover-without") - - - - - diff --git a/resources/views/pages/en/components/progress_bar.blade.php b/resources/views/pages/en/components/progress_bar.blade.php deleted file mode 100644 index cc1a4fc7..00000000 --- a/resources/views/pages/en/components/progress_bar.blade.php +++ /dev/null @@ -1,44 +0,0 @@ - - -Basics - - - The moonshine::progress-bar component allows you to create a progress bar - - -@include('pages.en.components.shared.colors') - - - - - - - @include("examples/components/progress_bar") - - - - -Radial - - - - - To create a radial progress indicator, you need to pass the radial parameter to the component with the value TRUE - - -@include('pages.en.components.shared.sizes') - - - - - @include("examples/components/progress_bar-radial") - - - - - diff --git a/resources/views/pages/en/components/rating.blade.php b/resources/views/pages/en/components/rating.blade.php deleted file mode 100644 index b2af1e2c..00000000 --- a/resources/views/pages/en/components/rating.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - The moonshine::rating component allows you to create stylized ratings - - - - - - - - @include("examples/components/rating") - - - - - diff --git a/resources/views/pages/en/components/shared/colors.blade.php b/resources/views/pages/en/components/shared/colors.blade.php deleted file mode 100644 index 16ae6346..00000000 --- a/resources/views/pages/en/components/shared/colors.blade.php +++ /dev/null @@ -1,13 +0,0 @@ - - Available colors: - - - - Purple - Pink - Blue - Green - Yellow - Red - Gray - diff --git a/resources/views/pages/en/components/shared/placement.blade.php b/resources/views/pages/en/components/shared/placement.blade.php deleted file mode 100644 index a2f91c4a..00000000 --- a/resources/views/pages/en/components/shared/placement.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - Available placement: - - - - bottom - top - left - right - diff --git a/resources/views/pages/en/components/shared/sizes.blade.php b/resources/views/pages/en/components/shared/sizes.blade.php deleted file mode 100644 index 38a524eb..00000000 --- a/resources/views/pages/en/components/shared/sizes.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - Available sizes: - - - - sm - md - lg - xl - diff --git a/resources/views/pages/en/components/shared/type.blade.php b/resources/views/pages/en/components/shared/type.blade.php deleted file mode 100644 index b23f124f..00000000 --- a/resources/views/pages/en/components/shared/type.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - Available types: - - - - success - info - warning - error - diff --git a/resources/views/pages/en/components/spinner.blade.php b/resources/views/pages/en/components/spinner.blade.php deleted file mode 100644 index e4575072..00000000 --- a/resources/views/pages/en/components/spinner.blade.php +++ /dev/null @@ -1,67 +0,0 @@ - -Basics - - - Using the moonshine::spinner component, you can create loading indicators - - - - - - - - @include("examples/components/spinner") - - - - -Size - -@include('pages.en.components.shared.sizes') - - - - - - - @include("examples/components/spinner-size") - - - - -Color - -@include('pages.en.components.shared.colors') - - - - - - - @include("examples/components/spinner-color") - - - - -Position - - - The absolute="true" parameter sets the absolute position of the loading indicator - - - - - - The fixed="true" parameter specifies a fixed positioning of the loading indicator - - - - - diff --git a/resources/views/pages/en/components/table.blade.php b/resources/views/pages/en/components/table.blade.php deleted file mode 100644 index 940f8fbb..00000000 --- a/resources/views/pages/en/components/table.blade.php +++ /dev/null @@ -1,103 +0,0 @@ - - -Basics - - - Styled tables can be created using the moonshine::table component - - - - - - - - @include("examples/components/table") - - - - -Crud mode - - - The crudMode parameter allows you to additionally style tables - - - - - - - @include("examples/components/table-crud") - - - -Not found - - - The notfound parameter allows you to display a message if there are no table elements - - - - - - - - @include("examples/components/table-notfound") - - - - -Slots - - - The table can be formed using slots - - - - - - - - @include("examples/components/table-slots") - - - - -Styles - - - To style the table, there are predefined classes that can be used for tr / td - - - - Available classes: - - - - bgc-purple - bgc-pink - bgc-blue - bgc-green - bgc-yellow - bgc-red - bgc-gray - - - - - - - - @include("examples/components/table-slots-color") - - - - - diff --git a/resources/views/pages/en/components/tabs.blade.php b/resources/views/pages/en/components/tabs.blade.php deleted file mode 100644 index dbd63d88..00000000 --- a/resources/views/pages/en/components/tabs.blade.php +++ /dev/null @@ -1,40 +0,0 @@ - - -Basics - - - To create tabs, you can use the moonshine::tabs component - - - - - - - - @include("examples/components/tabs") - - - - -Active tab - - - You can specify the default active tab by setting the activeTab. - - - - - - - - @include("examples/components/tabs-active") - - - - - diff --git a/resources/views/pages/en/components/thumbnail.blade.php b/resources/views/pages/en/components/thumbnail.blade.php deleted file mode 100644 index ae6a3443..00000000 --- a/resources/views/pages/en/components/thumbnail.blade.php +++ /dev/null @@ -1,46 +0,0 @@ - - -Basics - - - To create thumbnails, you can use the moonshine::thumbnails component - - - - - - - - @include("examples/components/thumbnails") - - - - - - You can also specify the attribute alt - - - - -Group of images - - - Component can be passed an array of images - - - - - - - - @include("examples/components/thumbnails-multiple") - - - - - diff --git a/resources/views/pages/en/components/title.blade.php b/resources/views/pages/en/components/title.blade.php deleted file mode 100644 index 5300ded3..00000000 --- a/resources/views/pages/en/components/title.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - If you want to place a stylized title, you can use the moonshine::title component - - - - - - - - @include("examples/components/title") - - - - - diff --git a/resources/views/pages/en/components/toast.blade.php b/resources/views/pages/en/components/toast.blade.php deleted file mode 100644 index d7797dcb..00000000 --- a/resources/views/pages/en/components/toast.blade.php +++ /dev/null @@ -1,39 +0,0 @@ - -Basics - - - Using the moonshine::toast component, you can create notifications - - - - -@include('pages.en.components.shared.type') - - - -
- @include("examples/components/toast-default") - @include("examples/components/toast-success") - @include("examples/components/toast-info") - @include("examples/components/toast-warning") - @include("examples/components/toast-error") -
- -Without use component - - - You can create a notification using the MoonShineUi::toast() method - - - -use MoonShine\MoonShineUI; - -MoonShineUi::toast('Toast content', 'error'); - - -
diff --git a/resources/views/pages/en/components/tooltip.blade.php b/resources/views/pages/en/components/tooltip.blade.php deleted file mode 100644 index cbdf8312..00000000 --- a/resources/views/pages/en/components/tooltip.blade.php +++ /dev/null @@ -1,38 +0,0 @@ - - -Basics - - - Using the moonshine::tooltip component, you can create handy tooltips - - -@include('pages.ru.components.shared.placement') - - - - - - - @include("examples/components/tooltip") - - - - -Without use component - - - - - - - @include("examples/components/tooltip-without") - - - - - diff --git a/resources/views/pages/en/concept.blade.php b/resources/views/pages/en/concept.blade.php deleted file mode 100644 index 444c0419..00000000 --- a/resources/views/pages/en/concept.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - The idea of the Moonshine project is to create a versatile and customizable admin panel for Laravel projects. - Almost all serious projects require an admin panel, and it takes a lot of time to create it. - So I've got an idea to make my own admin panel, but it's a huge job - and in a few years I managed to create a working version for the most common tasks. However, there are some serious drawbacks. - - - - Recently I saw the initiative in my CutCode community for Laravel to create their own open-source project, - and I’ve decided this was the proper approach to make a good admin panel together - by joining resources for a common target. - - - - Everyone will benefit from the interaction - you will be able to use a quality product that will always evolve. - - - - An active and vibrant community is the heart of the project. Therefore, the most active users will be encouraged. - What kind of incentive? The very first idea about the incentive is to create a system of donations. - Donated money is distributed among the main participants of the developer team. - Project MoonShine participates in the "Free License Programs" support program provided by JetBrains - - active developers receive a license for products from JetBrains. - - - - My goal is to make the project a place where developers will want to come back. - We can make a functional and comfortable machine together only! Together we will do more than one at a time! - - diff --git a/resources/views/pages/en/configuration.blade.php b/resources/views/pages/en/configuration.blade.php deleted file mode 100644 index ec0a18e1..00000000 --- a/resources/views/pages/en/configuration.blade.php +++ /dev/null @@ -1,102 +0,0 @@ - - - -use MoonShine\Exceptions\MoonShineNotFoundException; -use MoonShine\Models\MoonshineUser; - -return [ - # The directory where the resources are located - 'dir' => 'app/MoonShine', - # If you change the directory, you must also change the namespace according to psr-4 - 'namespace' => 'App\MoonShine', - - # Admin panel header - 'title' => env('MOONSHINE_TITLE', 'MoonShine'), - # You can change the logo by specifying the path (example - /images/logo.svg) - 'logo' => env('MOONSHINE_LOGO', '/images/logo.svg'), - 'logo_small' => env('MOONSHINE_LOGO_SMALL', '/images/logo-icon.svg'), - - 'route' => [ - # Which url will be available for the control panel (as a rule admin) - # If the value is left empty, the panel will be accessible from / - 'prefix' => env('MOONSHINE_ROUTE_PREFIX', 'moonshine'), - # Starting route in admin panel - 'index_route' => env('MOONSHINE_INDEX_ROUTE', 'moonshine.index'), - # Groups of middlewares in the panel - 'middleware' => ['moonshine'], - # Slug of the url formation for custom pages - 'custom_page_slug' => 'custom_page', - # You can change 404 error exception (for ModelNotFound you need to implement it yourself) - 'notFoundHandler' => MoonShineNotFoundException::class - ], - - # If you want to replace MoonshineUser with your own model, you can disable default migrations - 'use_migrations' => true, - # On/Off notifications - 'use_notifications' => true, - - 'auth' => [ - # On/Off authentication. If false, the panel will be available to all - 'enable' => true, - # If you use your own guard, provider - 'guard' => 'moonshine', - 'guards' => [ - 'moonshine' => [ - 'driver' => 'session', - 'provider' => 'moonshine', - ], - ], - 'providers' => [ - 'moonshine' => [ - 'driver' => 'eloquent', - 'model' => MoonshineUser::class, - ], - ], - # Text under the sign in button. As an example, you can add a sign-in button - 'footer' => '' - ], - # Possible translations - 'locales' => [ - 'en', 'ru' - ], - # Additional middlewares - 'middlewares' => [], - 'tinymce' => [ - # File manager root, see the Fields section for details - 'file_manager' => false, // or 'laravel-filemanager' prefix for lfm - 'token' => env('MOONSHINE_TINYMCE_TOKEN', ''), - 'version' => env('MOONSHINE_TINYMCE_VERSION', '6') - ], - # Authenticate via social networks and socialite, list the drivers and specify the logo - 'socialite' => [ - // 'driver' => 'path_to_image_for_button' - ], - # Template customization - 'header' => null, // blade path - 'footer' => [ - 'copyright' => 'Made with ❤️ by CutCode', - 'nav' => [ - 'https://github.com/moonshine/moonshine/blob/1.x/LICENSE.md' => 'License', - 'https://moonshine.cutcode.dev' => 'Documentation', - 'https://github.com/moonshine/moonshine' => 'GitHub', - ], - ] -]; - - - - For basic use it is enough to edit the parameters below - - - -return [ - // .. - 'title' => env('MOONSHINE_TITLE', 'MoonShine'), // [tl! focus] - 'logo' => env('MOONSHINE_LOGO', ''), // [tl! focus] - - 'route' => [ - 'prefix' => env('MOONSHINE_ROUTE_PREFIX', 'moonshine'), // [tl! focus] - ], - // .. - - diff --git a/resources/views/pages/en/contribution.blade.php b/resources/views/pages/en/contribution.blade.php deleted file mode 100644 index 8fb42a67..00000000 --- a/resources/views/pages/en/contribution.blade.php +++ /dev/null @@ -1,162 +0,0 @@ - - -What can you do to help? - - - Our community needs active users. You can help in many ways - - - - -We are using a technology stack - - - -Where do we start? - - - The product is working already, fully functional and testable. - But working doesn't mean great, so the goal is to make the project better. - - -Pull requests - - - You can suggest new features or improvements to MoonShine! Bugs and errors - all this could be documented and sent for improvement. - I'm also glad to meet new open source project development specialists - - -Where shall we discuss development? - - - For active participants in the project created a separate chat in telegram. If you are ready to participate in the development, - then join - MoonShine. - - - -If you found a mistake - - - 1. You have enough experience to offer a solution. - I would be very happy to receive your PR with a description of the error and a way to fix it. -
- 2. If you don't know how to solve the problem, create GitHub issues, and we will fix the problem soon. - -
* It is important that your pr passed all the tests of the platform and had a detailed description, - so that all participants of the development process understand what exactly happened.
-
- -Main branch - - - At the moment, the main branch is 1.5.x - - -Coding style - - - MoonShine adheres to the PSR-12 standard and PSR-4 autoload standard. - - -Developer's guide - -1 Make project dir and clone demo project - - - git clone git@github.com:moonshine-software/demo-project.git . - - -2 Add packages directory and execute the command below - - - cd packages && git clone git@github.com:moonshine-software/moonshine.git && cd moonshine && composer install && npm install - - -3 Go back to the project directory and remove moonshine/moonshine dependency from the composer.json - - - "moonshine/moonshine": "^1.50", - - -3 Add MoonShine from the packages directory to autoload section in the composer.json - - -"autoload": { - "psr-4": { - "App\\": "app/", - "Database\\Factories\\": "database/factories/", - "Database\\Seeders\\": "database/seeders/", - "MoonShine\\": "packages/moonshine/src" - } -}, - - -4 Add MoonShineServiceProvider to config/app.php - - -use App\Providers\MoonShineServiceProvider; -// Import vendor provider -use MoonShine\Providers\MoonShineServiceProvider as MSProvider; - -// .. - -/* -* Package Service Providers... -*/ -// Add vendor provider -MSProvider::class, - -// .. - - -5 Create .env from .env.example (don't forget to create a database) and complete the install below - - -composer require lee-to/laravel-package-command && composer require rap2hpoutre/fast-excel && composer install && npm install - - - -php artisan key:generate -php artisan storage:link -php artisan migrate --seed -php artisan moonshine:user -php artisan serve - - -# Make something great - -How to make a pull request? - - -Any questions? - - - My name is Danil! Email me at thecutcode@gmail.com - - -
diff --git a/resources/views/pages/en/decorations/block.blade.php b/resources/views/pages/en/decorations/block.blade.php deleted file mode 100644 index c55ea5a8..00000000 --- a/resources/views/pages/en/decorations/block.blade.php +++ /dev/null @@ -1,47 +0,0 @@ - - - - Substrate with header for form features - - - -use MoonShine\Decorations\Block; // [tl! focus] - -//... -public function fields(): array -{ - return [ - Block::make('Block title', [ // [tl! focus] - Text::make('Name', 'first_name'), - ]), // [tl! focus] - ]; -} -//... - - - - - - - If you don't need a header - - - -use MoonShine\Decorations\Block; // [tl! focus] - -//... -public function fields(): array -{ - return [ - Block::make([ // [tl! focus] - Text::make('Name', 'first_name'), - ]), // [tl! focus] - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/decorations/button.blade.php b/resources/views/pages/en/decorations/button.blade.php deleted file mode 100644 index 7be16367..00000000 --- a/resources/views/pages/en/decorations/button.blade.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - To add a button with a link to a form - - - -use MoonShine\Decorations\Button; - -//... -public function fields(): array -{ - return [ - Button::make( - 'Link to article', - $this->getItem() ? route('articles.show', $this->getItem()) : '/', - true - )->icon('clip'), - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/decorations/collapse.blade.php b/resources/views/pages/en/decorations/collapse.blade.php deleted file mode 100644 index eb3bb6a3..00000000 --- a/resources/views/pages/en/decorations/collapse.blade.php +++ /dev/null @@ -1,33 +0,0 @@ - - - - The Collapse decorator allows you to minimize fields and blocks while keeping their state - - - -use MoonShine\Decorations\Collapse; // [tl! focus] -use MoonShine\Decorations\Block; - -//... -public function fields(): array -{ - return [ - Block::make([ - Collapse::make('Title/Slug', [ // [tl! focus] - Text::make('Title') - ->fieldContainer(false), - - Text::make('Slug') - ->fieldContainer(false), - ]) // [tl! focus] - ->show() // Display expanded (optional) [tl! focus] - ]); - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/decorations/divider.blade.php b/resources/views/pages/en/decorations/divider.blade.php deleted file mode 100644 index 3c591871..00000000 --- a/resources/views/pages/en/decorations/divider.blade.php +++ /dev/null @@ -1,82 +0,0 @@ - - -Basics - - - To divide into areas, you can use the Divider decorator - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make(), // [tl! focus] - //... - ]; -} -//... - - - - - -Label - - - You can use text as a separator, for this you need to pass it to the make() method - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make('Divider'), // [tl! focus] - //... - ]; -} -//... - - - - - - - The centered() method allows you to center the text - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make('Divider') - ->centered(), // [tl! focus] - //... - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/decorations/heading.blade.php b/resources/views/pages/en/decorations/heading.blade.php deleted file mode 100644 index 8e7734c3..00000000 --- a/resources/views/pages/en/decorations/heading.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - You can add headers to separate areas of the form - - - -use MoonShine\Decorations\Heading; - -//... -public function fields(): array -{ - return [ - Heading::make('Title/Slug'), - - Text::make('Title') - ->fieldContainer(false), - Text::make('Slug') - ->fieldContainer(false), - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/decorations/index.blade.php b/resources/views/pages/en/decorations/index.blade.php deleted file mode 100644 index d1fb9a5e..00000000 --- a/resources/views/pages/en/decorations/index.blade.php +++ /dev/null @@ -1,10 +0,0 @@ - - - Decorations are set in the fields or filters resource methods. - - - - Improve the appearance of the fields and the quality of the interface - - - diff --git a/resources/views/pages/en/decorations/layout.blade.php b/resources/views/pages/en/decorations/layout.blade.php deleted file mode 100644 index f647d6cd..00000000 --- a/resources/views/pages/en/decorations/layout.blade.php +++ /dev/null @@ -1,94 +0,0 @@ - - - Sometimes it is necessary to divide the form into several blocks for convenience, by default they go under each other, but with the help of scenery Layout you can easily change the display - - -Flex - - - Changing the positioning of the fields in the line - - - -use MoonShine\Decorations\Flex; - - //... - public function fields(): array -{ - return [ - Flex::make([ - Text::make('Title'), - Text::make('Slug'), - ]) - // Additional options - ->withoutSpace() // Eliminate indentation - ->justifyAlign('start') // Based on tailwind classes justify-[param] - ->itemsAlign('start') // Based on tailwind classes items-[param] - ]; -} -//... - - - - - - - -Grid/Column - - - Grid with speakers - - - -use MoonShine\Decorations\Grid; -use MoonShine\Decorations\Column; - -//... -public function fields(): array -{ - return [ - Grid::make([ - Column::make([ - Block::make('Main information', [ - // Fields here - ]) - ])->columnSpan(6), // 6 out of 12 is half of the screen - - Column::make([ - Block::make('Contact information', [ - // Fields here - ]) - ])->columnSpan(6), // 6 out of 12 is half of the screen - ]) - ]; -} -//... - - - - The result is two columns with blocks - - - - - - diff --git a/resources/views/pages/en/decorations/tabs.blade.php b/resources/views/pages/en/decorations/tabs.blade.php deleted file mode 100644 index 27f9f80b..00000000 --- a/resources/views/pages/en/decorations/tabs.blade.php +++ /dev/null @@ -1,36 +0,0 @@ - - - You can add tabs and group fields in the form for convenience - - - -use MoonShine\Decorations\Block; -use MoonShine\Decorations\Tabs; -use MoonShine\Decorations\Tab; -use MoonShine\Fields\Text; - -//... -public function fields(): array -{ - return [ - Block::make('Main', [ - Tabs::make([ - Tab::make('Seo', [ - Text::make('Seo title') - ->fieldContainer(false), - //... - ]), - Tab::make('Categories', [ - //... - ]) - ]) - ]), - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/fields/belongs_to.blade.php b/resources/views/pages/en/fields/belongs_to.blade.php deleted file mode 100644 index 7b2c10c7..00000000 --- a/resources/views/pages/en/fields/belongs_to.blade.php +++ /dev/null @@ -1,140 +0,0 @@ - - - - Select - - -Basics - -Field for relationships in Laravel, BelongsTo type. Displayed as select. - - -use MoonShine\Fields\BelongsTo; // [tl! focus] - -//... -public function fields(): array -{ - return [ - // indicating the relationship - BelongsTo::make('Country', 'country', 'name') // [tl! focus] - // or you can field - BelongsTo::make('Country', 'country_id', 'name') // [tl! focus] - ]; -} -//... - - -The third argument with the "name" value is a field in the linked "countries" table to display the values. - - - - -You can also pass a resource with a field to display as a third parameter - - -use MoonShine\Fields\BelongsTo; -use App\MoonShine\Resources\CountryResource; // [tl! focus] - -//... -public function fields(): array -{ - return [ - BelongsTo::make('Country', 'country', new CountryResource()) // [tl! focus] - ]; -} -//... - - - -namespace App\MoonShine\Resources; - -use MoonShine\Resources\Resource; -use App\Models\Country; - -class CountryResource extends Resource -{ - //... - - public string $titleField = 'name'; // [tl! focus] - - //... -} - - -If you need a more complex value to display, you can pass a function to the third argument - - -use MoonShine\Fields\BelongsTo; - -//... -public function fields(): array -{ - return [ - BelongsTo::make( - 'Country', - 'country', - fn($item) => "$item->id.) $item->name" // [tl! focus] - ) - ]; -} -//... - - -Searching values - - - If you need to search among values, then you need to add the searchable() method. - - - -use MoonShine\Fields\BelongsTo; -use App\MoonShine\Resources\CountryResource; - -//... -public function fields(): array -{ - return [ - BelongsTo::make('Country', 'country', new CountryResource()) - ->searchable() // [tl! focus] - ]; -} -//... - - -@include('pages.en.fields.shared.async_search', ['field' => 'BelongsTo']) - -@include('pages.en.fields.shared.values_query', ['field' => 'BelongsTo']) - -Empty value - - - If you need the default value Null - - - -use MoonShine\Fields\BelongsTo; - -//... -public function fields(): array -{ - return [ - BelongsTo::make('Country', 'country') - ->nullable() // [tl! focus] - ]; -} -//... - - - - Don't forget to specify in the database table that the field can be Null. - - - diff --git a/resources/views/pages/en/fields/belongs_to_many.blade.php b/resources/views/pages/en/fields/belongs_to_many.blade.php deleted file mode 100644 index 6f88956e..00000000 --- a/resources/views/pages/en/fields/belongs_to_many.blade.php +++ /dev/null @@ -1,167 +0,0 @@ - - - - Select - - -Basics - -Field for relationships in Laravel, BelongsToMany type. - -Displayed as a group of checkboxes, you can also transform into select multiple. - - -use MoonShine\Fields\BelongsToMany; // [tl! focus] - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Categories', 'categories', 'name') // [tl! focus] - ]; -} -//... - - - - - -Pivot - -To implement pivot fields, use the fields() method. - - -use MoonShine\Fields\BelongsToMany; - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Contacts', 'contacts', 'name') - ->fields([ - Text::make('Contact', 'text'), - ]) // [tl! focus:-2] - ]; -} -//... - - - - - -@include('pages.en.fields.shared.async_search', ['field' => 'BelongsToMany']) - - - Requests must be customized via the asyncSearch() method, - don't use valuesQuery()! - - - - -Select - -To transform the display into select, use the select() method. - - -use MoonShine\Fields\BelongsToMany; - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Categories', 'categories', 'name') - ->select() // [tl! focus] - ]; -} -//... - - - - - -@include('pages.en.fields.shared.values_query', ['field' => 'BelongsToMany']) - -Tree - - - Sometimes it makes sense to display checkboxes with a hierarchy, example for categories that have nesting, - there is a tree() method for this. - - -use MoonShine\Fields\BelongsToMany; - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Categories', 'categories', 'name') - ->tree('parent_id') // Contact field // [tl! focus] - ]; -} -//... - - -onlyCount - - - If you want to display only the number of selected values on the index page, - then you should use the onlyCount() method. - - - -use MoonShine\Fields\BelongsToMany; - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Categories', 'categories', 'name') - ->onlyCount() // [tl! focus] - ]; -} -//... - - -inLine - - - By default, the index page will display the field as a table, - but if you want to display it in a line, you can use the inLine() method. - - - Optional parameters can be passed to the method: - - - - -use MoonShine\Fields\BelongsToMany; - -//... -public function fields(): array -{ - return [ - BelongsToMany::make('Categories', 'categories', 'name') - ->inLine(separator: ' ', badge: true) // [tl! focus] - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/fields/checkbox.blade.php b/resources/views/pages/en/fields/checkbox.blade.php deleted file mode 100644 index 60234387..00000000 --- a/resources/views/pages/en/fields/checkbox.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - The Checkbox field includes all the basic methods - - - -use MoonShine\Fields\Checkbox; - -//... - -public function fields(): array -{ - return [ - Checkbox::make('Label', 'table_field') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/code.blade.php b/resources/views/pages/en/fields/code.blade.php deleted file mode 100644 index ee01b9e8..00000000 --- a/resources/views/pages/en/fields/code.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - Textarea - - -Code Editor - - -use MoonShine\Fields\Code; - -//... -public function fields(): array -{ - return [ - Code::make('Code', 'code') - ->language('js') - ->lineNumbers() - ]; -} - -//... - - - - - - - - - diff --git a/resources/views/pages/en/fields/color.blade.php b/resources/views/pages/en/fields/color.blade.php deleted file mode 100644 index 2b3873ac..00000000 --- a/resources/views/pages/en/fields/color.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - Text - - - - Everything is the same as "Text field", the only difference is input type = color - - - -use MoonShine\Fields\Color; - -//... -public function fields(): array -{ - return [ - Color::make('Color') - ]; -} - -//... - - - - - - - - - diff --git a/resources/views/pages/en/fields/date.blade.php b/resources/views/pages/en/fields/date.blade.php deleted file mode 100644 index 1e7e4e90..00000000 --- a/resources/views/pages/en/fields/date.blade.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - Text - - - - Input has date type and additional method - format - - - -use MoonShine\Fields\Date; - -//... -public function fields(): array -{ - return [ - Date::make('Creation date', 'created_at') - ->format('d.m.Y') // Date display format on the main resource - ]; -} - -//... - - - - - - - Use the withTime method to display not only the date but also the time in the field - - - -use MoonShine\Fields\Date; - -//... -public function fields(): array -{ - return [ - Date::make('Date and time of creation', 'created_at') - ->withTime() - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/email.blade.php b/resources/views/pages/en/fields/email.blade.php deleted file mode 100644 index 65d71219..00000000 --- a/resources/views/pages/en/fields/email.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - Text - - - - Everything is the same as "Text field", the only difference is input type = email - - - -use MoonShine\Fields\Email; - -Email::make('E-mail', 'email') - - - diff --git a/resources/views/pages/en/fields/enum.blade.php b/resources/views/pages/en/fields/enum.blade.php deleted file mode 100644 index c06586fe..00000000 --- a/resources/views/pages/en/fields/enum.blade.php +++ /dev/null @@ -1,30 +0,0 @@ - - - - Select - - - - Works the same as the Select field but accepts Enum - - - - Model attribute requires EnumCast - - - -use MoonShine\Fields\Enum; - -//... - -public function fields(): array -{ - return [ - Enum::make('Status', 'status_id')->attach(EnumStatus::class) - ]; -} - -//... - - - diff --git a/resources/views/pages/en/fields/file.blade.php b/resources/views/pages/en/fields/file.blade.php deleted file mode 100644 index 418e8b33..00000000 --- a/resources/views/pages/en/fields/file.blade.php +++ /dev/null @@ -1,217 +0,0 @@ - - - - Before using the file field, - make sure that a symbolic link is set to the storage directory - - - - php artisan storage:link - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - // [tl! focus:start] - File::make('File', 'file') - ->dir('/') // The directory where the files will be stored in storage (by default /) - ->disk('public') // Filesystems disk - ->allowedExtensions(['jpg', 'gif', 'png']) // Allowable extensions - // [tl! focus:end] - //... - ]; -} -//... - - - - - - - To correctly generate the file URL, you must define the environment variable APP_URL in this way, - to match your app's URL. - - - - When using the local driver, the return value of url is not URL encoded. - For this reason, we recommend always storing your files using names that will create valid URLs. - - -Multiple - - - The multiple() method is used to upload multiple files - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->multiple(), // [tl! focus] - //... - ]; -} -//... - - - - The field in the database must be of text or json type.
- You also need to add cast for eloquent model - json or array or collection. -
- -Removing files - - - To be able to delete files, you must use the removable() method - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->removable(), // [tl! focus] - //... - ]; -} -//... - - - - The disableDeleteFiles() method will allow you to delete only the record in the database, - but not delete the file itself - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->removable() - ->disableDeleteFiles(), // [tl! focus] - //... - ]; -} -//... - - - - The enableDeleteDir() method deletes the directory specified in the dir() method if it is empty - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->dir('/images/') - ->removable() - ->enableDeleteDir(), // [tl! focus] - //... - ]; -} -//... - - -Disabling download - - - If you want to protect the file from download, you must use the disableDownload() method - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->disableDownload(), // [tl! focus] - //... - ]; -} -//... - - -Original filename - - - If you want to keep the original filename received from the client, use the keepOriginalFileName() method - - - -use MoonShine\Fields\File; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->keepOriginalFileName(), // [tl! focus] - //... - ]; -} -//... - - -Custom file name - - - If you need to save a custom file name, use the method customName('file_name')) - - - -use MoonShine\Fields\File; -use Illuminate\Http\UploadedFile; -use Illuminate\Support\Str; - -//... -public function fields(): array -{ - return [ - //... - File::make('File', 'file') - ->customName(fn(UploadedFile $file) => Str::random(10) . '.' . $file->extension()), // [tl! focus] - //... - ]; -} -//... - - -
diff --git a/resources/views/pages/en/fields/has_many.blade.php b/resources/views/pages/en/fields/has_many.blade.php deleted file mode 100644 index 8f97279d..00000000 --- a/resources/views/pages/en/fields/has_many.blade.php +++ /dev/null @@ -1,70 +0,0 @@ - - -Field for relationships in Laravel, hasMany type - - -use MoonShine\Fields\HasMany; - -//... -public function fields(): array -{ - return [ - HasMany::make('Comments') - ->fields([ - ID::make(), - BelongsTo::make('Article'), - BelongsTo::make('User'), - Text::make('Text')->required(), - ]) - ->removable() - ]; -} -//... - - - - ID in the fields method is required - - - - It often happens that there are a lot of fields for relations and they look small in the table, and this is inconvenient. - In many cases, you have to move this relation to a separate resource, however if you must leave it within the current resource, - but display the fields completely, - you can use the fullPage() method, and the fields will get a standard shape - - - - - - - Anyway, the table and fullPage modes are more suitable for relations with primitive fields, such modes - do not support Json, HasOne, HasMany fields and many others. - But you can switch the field to ResourceMode to render a list of related records, or a related form - as a standalone resource. - To do this, you need to specify the resourceMode() method for the field and in this case you shouldn't specify the field set - in the fields() method, but the resource associated with the fields will be required - - - -use MoonShine\Fields\HasMany; - -//... -public function fields(): array -{ - return [ - HasMany::make('Rates', 'prices', new PriceResource()) - ->resourceMode() - ]; -} -//... - - - - Pay attention that the presence of a resource in this mode is a mandatory criterion. - However, it can be omitted if it does not violate the naming convention. As a result of which, it will be found automatically. - - - - - - diff --git a/resources/views/pages/en/fields/has_many_through.blade.php b/resources/views/pages/en/fields/has_many_through.blade.php deleted file mode 100644 index 207b00c9..00000000 --- a/resources/views/pages/en/fields/has_many_through.blade.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - HasMany - - -Field for relationships in Laravel, hasManyThrough type - -Same as MoonShine\Fields\HasMany only for hasManyThrough relationships - -MoonShine\Fields\hasManyThrough - - diff --git a/resources/views/pages/en/fields/has_one.blade.php b/resources/views/pages/en/fields/has_one.blade.php deleted file mode 100644 index c6edd1a2..00000000 --- a/resources/views/pages/en/fields/has_one.blade.php +++ /dev/null @@ -1,51 +0,0 @@ - - - - HasMany - - -Field for relationships in Laravel, hasOne type - -Creates a new record in the linked table and binds it to the current record - -In case of relationship the record is edited - - -use MoonShine\Fields\HasOne; - -//... -public function fields(): array -{ - return [ - HasOne::make('City', 'city', 'name') - ->fields([ - ID::make(), - Text::make('Value', 'name'), - ]) - ]; -} -//... - - - - ID in the fields method is required - - - - It often happens that there are a lot of fields for relations and they look small in the table, and this is inconvenient. - In many cases, you have to move this relation to a separate resource, however if you must leave it within the current resource, - but display the fields completely, you can use - the fullPage() method, and the fields will get a standard shape - - - - - - - - - - resourceMode is also available, details in the HasMany field - - - diff --git a/resources/views/pages/en/fields/has_one_through.blade.php b/resources/views/pages/en/fields/has_one_through.blade.php deleted file mode 100644 index 9021819a..00000000 --- a/resources/views/pages/en/fields/has_one_through.blade.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - HasOne - - -Field for relationships in Laravel, hasOneThrough type - -Same as MoonShine\Fields\HasOne but for hasOneThrough relationships - -MoonShine\Fields\HasOne - - diff --git a/resources/views/pages/en/fields/id.blade.php b/resources/views/pages/en/fields/id.blade.php deleted file mode 100644 index 7e18db11..00000000 --- a/resources/views/pages/en/fields/id.blade.php +++ /dev/null @@ -1,42 +0,0 @@ - - - - Text - - - - It is almost always present and will be hidden by default on the add/edit page. - If the primary key has a name other than id you have to specify its name as the first argument of the make method. - - - -use MoonShine\Fields\ID; // [tl! focus] - -//... - -public function fields(): array -{ - return [ - ID::make() // [tl! focus] - ]; -} - -//... - - - -use MoonShine\Fields\ID; // [tl! focus] - -//... - -public function fields(): array -{ - return [ - ID::make('primary_key') // [tl! focus] - ]; -} - -//... - - - diff --git a/resources/views/pages/en/fields/image.blade.php b/resources/views/pages/en/fields/image.blade.php deleted file mode 100644 index ede3759e..00000000 --- a/resources/views/pages/en/fields/image.blade.php +++ /dev/null @@ -1,42 +0,0 @@ - - - - File - - - - Everything is the same as File, only the display changes - - - -use MoonShine\Fields\Image; - -//... -public function fields(): array -{ - return [ - //... [tl! focus:start] - Image::make('Thumbnail', 'thumbnail') - ->dir('/') // The directory where the files will be stored in storage (by default /) - ->disk('public') // Filesystems disk - ->allowedExtensions(['jpg', 'gif', 'png']) // Allowable extensions - //... [tl! focus:end] - ]; -} -//... - - - - - - - To correctly generate the file URL, you must define the environment variable APP_URL in this way, - to match your app's URL. - - - - When using the local driver, the return value of url is not URL encoded. - For this reason, we recommend always storing your files using names that will create valid URLs. - - - diff --git a/resources/views/pages/en/fields/index.blade.php b/resources/views/pages/en/fields/index.blade.php deleted file mode 100644 index 62f6f57b..00000000 --- a/resources/views/pages/en/fields/index.blade.php +++ /dev/null @@ -1,502 +0,0 @@ - - - - Fields is one of the most important sections along with resources. - We have already discussed the process of Fields registration in the Resource section, - but let's figure out how to customize them to your needs! The fluent interface is used for convenience - - -Make - - - First of all, let's understand how the make method works when creating an instance of a field - - - -Text::make(string $label = null, string $column = null, ResourceContract|string|null $resource = null) - - - - $label - Label, field header
- $column - A field in the database (e.g. name) or a relation (e.g. countries)
- $resource - If $field is a relation, then in this parameter you need to specify a field - in the linked table that will be displayed in the view -
- - - $resource can also be a Resource class. In this case, if the - $titleField property is specified, the field of the relation will be defined through it - - - -//... -class MoonShineUserResource extends Resource -{ -public static string $model = MoonshineUser::class; - -public static string $title = 'Administrators'; - -public string $titleField = 'name'; // [tl! focus] -//... - - -Displaying - - - The fields are displayed at the page (the main page of the resource) and at the create/edit page. - To exclude the field from the main page or the page with the form, you can use - hideOnIndex/hideOnForm/hideOnDetail methods and showOnIndex/showOnForm/showOnDetail reverse methods. - To exclude it from the edit or add page only - - use hideOnCreate/hideOnUpdate/showOnCreate/showOnUpdate - - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - ID::make(), - Text::make('Title', 'title') - // [tl! focus:start] - ->hideOnIndex() - ->hideOnForm() - // [tl! focus:end] - , - ]) - ]; -} - -//... - - -Conditional display - - - This method also accepts bool, or Closure - - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - ID::make(), - Text::make('Title', 'title') - // [tl! focus:start] - ->hideOnIndex(auth()->check()) - // [tl! focus:end] - , - ]) - ]; -} - -//... - - -Attributes - - - As the form renders the html element, you can use basic html attributes as well. - Such as disabled, autocomplete, readonly, multiple etc. - - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - Text::make('Title', 'title') - ->disabled() // [tl! focus] - ->hidden() // [tl! focus] - ->readonly(), // [tl! focus] - ]; - ]) - } - -//... - - -Arbitrary attributes - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - Password::make('Password', 'password') - ->customAttributes(['autocomplete' => 'off']) // [tl! focus] - ]) - ]; -} - -//... - - -Required field - - - To make the field mandatory, you must use the required method - - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - Text::make('Title', 'title') - ->required() // [tl! focus] - ]) - ]; -} - -//... - - -Dynamic value - - -//... - -public function fields(): array -{ - return [ - Block::make('Block title', [ - Text::make('Name', 'first_name', fn($item) => $item->first_name . ' ' . $item->last_name) - - // Example if you want to separate the logic for the main and for editing - Text::make('Price', resource: function ($item) { - if(request()->routeIs('*.index')) { - return $item->price; - } - - return $item->exists ? $item->price->raw() : 0; - }), - ]) - ]; -} - -//... - - -Hint - - - You can add a hint with a description to the field by calling the hint - - - -//... - -public function fields(): array -{ - return [ - Number::make('Rating') - ->hint('From 0 to 5') // [tl! focus] - ->min(0) - ->max(5) - ->stars() - ]; -} - -//... - - - - - -Link - - - You can add a link to the field (e.g. with instructions) - addLink(string $name, string $link, bool $blank = false) - - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->addLink('YouTube', 'https://youtube.com') // [tl! focus] - // or with the anonymous function - ->addLink('Test', function() { - if(!$this->getItem()) { - return route('admin.brands.index'); - } - - return route('admin.brands.edit', $this->getItem()->brand_id); - }), - ]; -} - -//... - - - - - -Nullable - - - If you want to save NULL nullable() by default - - -Sorting - - - To be able to sort the field on the main page of the resource, you must add the sortable method - - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->sortable() // [tl! focus] - ]; -} - -//... - - -Hide label - - - The fieldContainer method hides Label fields to save space, - especially useful in conjunction with the Flex decoration - - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->fieldContainer(false) // [tl! focus] - ]; -} - -//... - - -Default value - - - Use the default method if you want to specify a default value for the field - - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->default('-') // [tl! focus] - ]; -} - -//... - - -Display condition - - - There may be a need to display a field only if the value of another field - in the form has a certain value (For example: display the phone only if there is a check mark for it). - For these purposes, the showWhen($column, $operator, $value) method is used - - - - Available operators: - - - - = - < - > - <= - >= - != - in - not in - - - - If the operator is not specified, then = will be used - - - -//... - -public function fields(): array -{ - return [ - Phone::make('Phone', 'phone') - ->showWhen('has_phone','=', 1) // [tl! focus] - // или - Phone::make('Phone', 'phone') - ->showWhen('has_phone', 1) // [tl! focus] - ]; -} - -//... - - - - If the statement is in or not in, - then in $value you need to pass an array - - - -//... - -public function fields(): array -{ - return [ - Select::make('List', 'list')->multiple()->options([ - 'value 1' => 'Option Label 1', - 'value 2' => 'Option Label 2', - 'value 3' => 'Option Label 3', - ]), - - Text::make('Name', 'name') - ->showWhen('list', 'not in', ['value 1', 'value 3']), // [tl! focus] - - Textarea::make('Content', 'content') - ->showWhen('list', 'in', ['value 2', 'value 3']) // [tl! focus] - ]; -} - -//... - - -Ability to save - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->canSave(false) // [tl! focus] - // or - ->canSave(fn() => false) // [tl! focus] - ]; -} - -//... - - -Events - - - When writing your own Fields, you may need to interact with events before and after saving. - To do this, you have to implement the relevant methods in your custom field - - - -public function beforeSave(Model $item): void -{ - // -} - -public function afterSave(Model $item): void -{ - // -} - - -Change view - - - Sometimes it makes sense to change the view using a fluent interface - (For example, if you use filters or fields outside of MoonShine) - - - -Text::make('Title') - ->customView('fields.my-custom-input'), - - -Methods by condition - - - The when method implements the fluent interface - and will execute a callback when the first argument, passed to the method is true. - - - -Text::make('Slug') - ->when(isset($this->getItem()->id), fn(Text $field) => $field->locked()), - - - - The field instance will be passed to the callback function. - - - - The second callback can be passed to the when method, it will be executed, - when the first argument passed to the method has a false value. - - - -Text::make('Slug') - ->when( - isset($this->getItem()->id), - fn(Text $field) => $field->locked(), - fn(Text $field) => $field->hidden() - ), - - - - The unless method is the reverse of the when method and will execute the first callback, - when the first argument has a false value, otherwise the second callback will be executed if it was passed to the method. - - - -Text::make('Slug') - ->unless( - auth('moonshine')->user()->moonshine_user_role_id === 1, - fn(Text $field) => $field->readonly()->hideOnCreate(), - fn(Text $field) => $field->locked() - ), - - -
diff --git a/resources/views/pages/en/fields/json.blade.php b/resources/views/pages/en/fields/json.blade.php deleted file mode 100644 index aceb7dec..00000000 --- a/resources/views/pages/en/fields/json.blade.php +++ /dev/null @@ -1,90 +0,0 @@ - - - - In the database, the field must be of type text or json. Also cast eloquent array or json or collection models. - - -Key/Value - - - The easiest way is to use the keyValue method, in which case the database will have a simple json [{key: value}] - - - -use MoonShine\Fields\Json; - -//... -public function fields(): array -{ - return [ - Json::make('Product Options', 'options') // [tl! focus] - ->keyValue('Characteristic', 'Value') // First argument Key label, second argument Value label [tl! focus] - ]; -} -//... - - - - - -With a set of fields - - - For more advanced use, use the fields method and pass the required set of fields in a similar way to how the resource works - - - -use MoonShine\Fields\Json; - -//... -public function fields(): array -{ - return [ - Json::make('Product Options', 'options') // [tl! focus:start] - ->fields([ - Text::make('Title', 'title'), - Text::make('Value', 'value') - ]) // [tl! focus:end] - ]; -} -//... - - - - json [{title: 'value', value: 'value'}] - - - - - -Deleting - - -Json::make('Product Options', 'options') - ->keyValue('Characteristics', 'Value') - ->removable() // [tl! focus] - - - - - -Value only - - - Sometimes you only need to store the values in the database - for this you can use the onlyValue() method. - - - -Json::make('Product Options', 'options') - ->onlyValue() // [tl! focus] - - - diff --git a/resources/views/pages/en/fields/morph_many.blade.php b/resources/views/pages/en/fields/morph_many.blade.php deleted file mode 100644 index 21ce53a1..00000000 --- a/resources/views/pages/en/fields/morph_many.blade.php +++ /dev/null @@ -1,13 +0,0 @@ - - - - HasMany - - -Field for relationships in Laravel, morphMany type - -Same as MoonShine\Fields\HasMany only for morphMany relations - -MoonShine\Fields\MorphMany - - diff --git a/resources/views/pages/en/fields/morph_one.blade.php b/resources/views/pages/en/fields/morph_one.blade.php deleted file mode 100644 index 396b62f7..00000000 --- a/resources/views/pages/en/fields/morph_one.blade.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - HasOne - - -Field for relationships in Laravel, morphOne type - -Same as MoonShine\Fields\HasOne but for MorphOne relations - -MoonShine\Fields\MorphOne - - - - - diff --git a/resources/views/pages/en/fields/morph_to.blade.php b/resources/views/pages/en/fields/morph_to.blade.php deleted file mode 100644 index 353bf7b6..00000000 --- a/resources/views/pages/en/fields/morph_to.blade.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - BelongsTo - - -Relationship field in Laravel like MorphTo - -Same as MoonShine\Fields\BelongsTo but for MorphTo relationships - - -use MoonShine\Fields\MorphTo; - -//... - -public function fields(): array -{ - return [ - MorphTo::make('Commentable')->types([ - Article::class => 'title' - ]), - ]; -} -//... - - - - Required types method specifying the classes available.
- The key is a reference to the model, and the value is the field to display. -
- - - - -
diff --git a/resources/views/pages/en/fields/morph_to_many.blade.php b/resources/views/pages/en/fields/morph_to_many.blade.php deleted file mode 100644 index 1c42d29a..00000000 --- a/resources/views/pages/en/fields/morph_to_many.blade.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - BelongsToMany - - -Field for relationships in Laravel, MorphToMany type - -Same as MoonShine\Fields\BelongsToMany only for MorphToMany relationships - -MoonShine\Fields\MorphToMany - - - - - diff --git a/resources/views/pages/en/fields/no_input.blade.php b/resources/views/pages/en/fields/no_input.blade.php deleted file mode 100644 index 124903e2..00000000 --- a/resources/views/pages/en/fields/no_input.blade.php +++ /dev/null @@ -1,106 +0,0 @@ - - - - The field is not for data input/amendment! - - -Basic application - - - With this default field, you can display text data from any field in the model, - or generate text based on the model. - - - -//... -use MoonShine\Fields\NoInput; - -public function fields(): array -{ - return [ - NoInput::make('No input field', 'no_input', static fn() => fake()->realText()), - ]; -} - -//... - - - - - -Badge - - - Displays a label, could be used for order status, as an example! - We use the badge method with a color parameter, - which can be either a string or a closure with the current element in the parameter - - - -//... -use MoonShine\Fields\NoInput; - -public function fields(): array -{ - return [ - NoInput::make('Status')->badge(fn($item) => $item->status_id === 1 ? 'green' : 'gray'), - ]; -} - -//... - - -Boolean - - - Display a label (green or red) for boolean values. - Using the hideTrue and hideFalse options you can hide the label for values input - - - -//... -use MoonShine\Fields\NoInput; - -public function fields(): array -{ - return [ - NoInput::make('Active')->boolean(hideTrue: false, hideFalse: false), - ]; -} - -//... - - -Link - - - Displays a link. - We can show the value and specify the link using the parameter (string or closure with the current element) - - - -//... -use MoonShine\Fields\NoInput; - -public function fields(): array -{ - return [ - NoInput::make('Link')->link('https://cutcode.dev', blank: false), - NoInput::make('Link')->link(fn($item) => $item->link, blank: true), - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/number.blade.php b/resources/views/pages/en/fields/number.blade.php deleted file mode 100644 index 79d0ab8a..00000000 --- a/resources/views/pages/en/fields/number.blade.php +++ /dev/null @@ -1,48 +0,0 @@ - - - - Text - - - - Input with the number type and additional methods: stars, min, max - - - -use MoonShine\Fields\Number; - -//... -public function fields(): array -{ - return [ - Number::make('Rating', 'rating') - ->min(1) - ->max(5) - ]; -} - -//... - - - - To display a numerical value as stars (e.g. for rating), you need the stars method - - - -use MoonShine\Fields\Number; - -//... -public function fields(): array -{ - return [ - Number::make('Rating', 'rating') - ->stars() // [tl! focus] - ->min(1) - ->max(5) - ]; -} - -//... - - - diff --git a/resources/views/pages/en/fields/password.blade.php b/resources/views/pages/en/fields/password.blade.php deleted file mode 100644 index e3590c87..00000000 --- a/resources/views/pages/en/fields/password.blade.php +++ /dev/null @@ -1,33 +0,0 @@ - - - - Text - - - - Everything is the same as the "Text field", the only difference is input type = password - - - - And usually it could be accompanied with the password confirmation field - - - -use MoonShine\Fields\Password; -use MoonShine\Fields\PasswordRepeat; - -//... - -public function fields(): array -{ - return [ - Password::make('Password', 'password')->hideOnIndex(), // [tl! focus] - PasswordRepeat::make('Repeat password', 'password_repeat')->hideOnIndex(), // [tl! focus] - ]; -} - -//... - - - - diff --git a/resources/views/pages/en/fields/phone.blade.php b/resources/views/pages/en/fields/phone.blade.php deleted file mode 100644 index 4715c10d..00000000 --- a/resources/views/pages/en/fields/phone.blade.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - Text - - - - Everything is the same as the "Text field", the only difference is input type = tel - - - -use MoonShine\Fields\Phone; - -Phone::make('Phone', 'tel') - - -To mask the telephone number, use the mask('7 999 999-99-99') method - - diff --git a/resources/views/pages/en/fields/select.blade.php b/resources/views/pages/en/fields/select.blade.php deleted file mode 100644 index 47e73726..00000000 --- a/resources/views/pages/en/fields/select.blade.php +++ /dev/null @@ -1,105 +0,0 @@ - - - - The text field includes all the basic methods and additional methods for select fields - - - -use MoonShine\Fields\Select; - -//... - -public function fields(): array -{ - return [ - Select::make('Country', 'country_id') - ->options([ - 'value 1' => 'Option Label 2', - 'value 2' => 'Option Label 2' - ]) - ]; -} - -//... - - - - - -Nullable - - - If you need to save NULL, then you need to add a nullable method - - - - Select::make('Country', 'country_id') - ->nullable() // [tl! focus] - - - - - -Groups - - - You can combine values into groups - - - -Select::make('City')->options([ - 'Italy' => [ - 1 => 'Rome', - 2 => 'Milan' - ], - 'France' => [ - 3 => 'Paris', - 4 => 'Marseille' - ], -]), - - - - - -Multiple select - - - To select multiple values, you need the multiple method - - - -Select::make('Country', 'country_id') - ->multiple() // [tl! focus] - - - - The field in the database must be of the text or json type.
- You also need to add a cast for the eloquent model - json or array or collection. -
- - - - -Search - - - If you want to add a search among values, you need to add the searchable method - - - - Select::make('Country', 'country_id') - ->searchable() // [tl! focus] - - - - - -
diff --git a/resources/views/pages/en/fields/shared/async_search.blade.php b/resources/views/pages/en/fields/shared/async_search.blade.php deleted file mode 100644 index 9172f369..00000000 --- a/resources/views/pages/en/fields/shared/async_search.blade.php +++ /dev/null @@ -1,90 +0,0 @@ -Async search - - - Async search for values is provided by the asyncSearch() method. - - - -use MoonShine\Fields\{{ $field }}; // [tl! focus] - -//... -public function fields(): array -{ - return [ - {{ $field }}::make('Contacts') // [tl! focus] - ->asyncSearch(){!!$field === 'BelongsToMany' ? "->fields([Text::make('Contact', 'text')])" : ""!!} // [tl! focus] - ]; -} -//... - - - - The search will be performed on the resource relation field titleField. The default is titleField=id. - - - - You can pass parameters to the asyncSearch() method: - - - - - - - -use Illuminate\Contracts\Database\Eloquent\Builder; // [tl! focus] -use MoonShine\Fields\{{ $field }}; // [tl! focus] - -//... -public function fields(): array -{ - return [ - {{ $field }}::make('Contacts')->asyncSearch( - 'title', - 10, - asyncSearchQuery: function (Builder $query) { - return $query->where('id', '!=', 2); - }, - asyncSearchValueCallback: function ($contact) { - return $contact->id . ' | ' . $contact->title; - } - ){!!$field === 'BelongsToMany' ? "->fields([Text::make('Contact', 'text')])" : ""!!} // [tl! focus:-9] - ]; -} -//... - - - - When building a query in asyncSearchQuery(), you can use the current form values. - To do this, you need to pass Request to the callback functions. - - - -use Illuminate\Contracts\Database\Eloquent\Builder; // [tl! focus] -use Illuminate\Http\Request; // [tl! focus] -use MoonShine\Fields\{{ $field }}; -use MoonShine\Fields\Select; - -//... -public function fields(): array -{ - return [ - Select::make('Country', 'country_id'), // [tl! focus] - {{ $field }}::make('City')->asyncSearch( - 'title', - asyncSearchQuery: function (Builder $query, Request $request): Builder { - return $query->where('country_id', $request->get('country_id')); - } // [tl! focus:-2] - ) - ]; -} -//... - - - - Relations that use async search in their fields are recommended to be used in ResourceMode. - diff --git a/resources/views/pages/en/fields/shared/values_query.blade.php b/resources/views/pages/en/fields/shared/values_query.blade.php deleted file mode 100644 index 71793e18..00000000 --- a/resources/views/pages/en/fields/shared/values_query.blade.php +++ /dev/null @@ -1,18 +0,0 @@ -Values query - -To filter values, use the valuesQuery method - - -use Illuminate\Contracts\Database\Eloquent\Builder; // [tl! focus] -use MoonShine\Fields\{{ $field }}; - -//... -public function fields(): array -{ - return [ - {{ $field }}::make('Categories', 'categories', 'name') - ->valuesQuery(fn(Builder $query) => $query->where('active', true)) // [tl! focus] - ]; -} -//... - diff --git a/resources/views/pages/en/fields/slide.blade.php b/resources/views/pages/en/fields/slide.blade.php deleted file mode 100644 index 526907b2..00000000 --- a/resources/views/pages/en/fields/slide.blade.php +++ /dev/null @@ -1,39 +0,0 @@ - - - - Text - - - - Has the same methods as the "Number" field, plus additional methods: step, - fromField, toField - - - - Since the range has two values, you have to specify these two fields in the database by means of - fromField and toField methods - - - -use MoonShine\Fields\SlideField; - -//... -public function fields(): array -{ - return [ - SlideField::make('Age') - ->fromField('age_from') // Field in the table for the value "From" - ->toField('age_to') // Field in the table for the value "Before" - ->min(0) - ->max(60) - ->step(1) // Slider pitch - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/slug.blade.php b/resources/views/pages/en/fields/slug.blade.php deleted file mode 100644 index 901cbaa5..00000000 --- a/resources/views/pages/en/fields/slug.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - Text - - - - Using this field you can generate a slug based on the selected field and keep it unique too - - - -//... -use MoonShine\Fields\Slug; - -public function fields(): array -{ - return [ - Slug::make('Slug')->from('title')->separator('-')->unique(), - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/spatie/medialibrary.blade.php b/resources/views/pages/en/fields/spatie/medialibrary.blade.php deleted file mode 100644 index a45e33af..00000000 --- a/resources/views/pages/en/fields/spatie/medialibrary.blade.php +++ /dev/null @@ -1,88 +0,0 @@ - - - - Image - - - - This field belongs to a separate package, you have to complete the installation before using it - - - - composer require visual-ideas/moonshine-spatie-medialibrary - - - - The field is purposed for work with the - Laravel-medialibrary - package made by - Spatie - - - - Before using the Spatie\MediaLibrary field, make sure that: - - - - - - In the model: - - -use Spatie\MediaLibrary\HasMedia; -use Spatie\MediaLibrary\InteractsWithMedia; - -class ModelClass extends Model implements HasMedia - //... - use InteractsWithMedia; - - //... - public function registerMediaCollections(): void - { - $this->addMediaCollection('cover'); - } - //... - - - - In the MoonShine-resource: - - - use VI\MoonShineSpatieMediaLibrary\Fields\MediaLibrary; - //... - MediaLibrary::make('Cover', 'cover'), - //... - - - - By default, the field works in a single image mode - - -use Spatie\MediaLibrary\HasMedia; -use Spatie\MediaLibrary\InteractsWithMedia; - -class ModelClass extends Model implements HasMedia -//... -use InteractsWithMedia; -//... -public function registerMediaCollections(): void -{ - $this->addMediaCollection('cover')->singleFile(); -} -//... - - - If you want to use a field to load multiple images, add the ->multiple() method when declaring the field - - -//... -MediaLibrary::make('Gallery', 'gallery')->multiple(), -//... - - - - diff --git a/resources/views/pages/en/fields/spatie/translatable.blade.php b/resources/views/pages/en/fields/spatie/translatable.blade.php deleted file mode 100644 index 537d2344..00000000 --- a/resources/views/pages/en/fields/spatie/translatable.blade.php +++ /dev/null @@ -1,99 +0,0 @@ - - - - Json - - - - This field belongs to a separate package, you have to complete the installation before using it - - - - composer require visual-ideas/moonshine-spatie-translatable - - - - The field is purposed for work with the - Laravel-translatable - package made by - Spatie - - - - Before using the Spatie\Translatable field, make sure that: - - - - - -use VI\MoonShineSpatieTranslatable\Fields\Translatable; -//... -Translatable::make('Title', 'name') -//... - - -Mandatory translations - - - The ->requiredLanguages(array $languages) method is used to specify the languages required by the validator for creating/saving a record. - - - - It is recommended to pass the config('app.fallback_locale') value to this method - - - - -use VI\MoonShineSpatieTranslatable\Fields\Translatable; -//... -Translatable::make('Title', 'name') - ->requiredLanguages([config('app.fallback_locale'), 'ru']) -//... - - -Recommended translations - - - If you specify this array, the language codes in the forms for adding/modifying a specific translation will be placed at the beginning of the list of all possible languages. - - - -use VI\MoonShineSpatieTranslatable\Fields\Translatable; -//... -Translatable::make('Title', 'name') - ->priorityLanguages([config('app.fallback_locale'), config('app.locale'), 'de', 'fr', 'uk']) -//... - - -Deleting - - - You can delete specific translations from out of the entered ones - - - -Translatable::make('Field', 'field') - ->removable() // [tl! focus] - - - - If you leave the translation text blank, it will be deleted! - - - - If there are two translations into the same language, the translation that comes first will be deleted (replaced)! - - - - - - diff --git a/resources/views/pages/en/fields/stack_fields.blade.php b/resources/views/pages/en/fields/stack_fields.blade.php deleted file mode 100644 index 3f022046..00000000 --- a/resources/views/pages/en/fields/stack_fields.blade.php +++ /dev/null @@ -1,37 +0,0 @@ - - - - The StackFields field allows you to group fields when displayed on the index page. - - - - The fields() method needs to pass an array of fields for grouping. - - - - The withLabels() method can be used to display labels on the index page - - - -use MoonShine\Fields\BelongsTo; -use MoonShine\Fields\StackFields; // [tl! focus] -use MoonShine\Fields\Text; -//... - -public function fields(): array -{ - return [ - StackFields::make('Title')->fields([ // [tl! focus] - Text::make('Title'), - BelongsTo::make('Author', resource: 'name'), - ]) // [tl! focus] - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/switch.blade.php b/resources/views/pages/en/fields/switch.blade.php deleted file mode 100644 index ce3a5861..00000000 --- a/resources/views/pages/en/fields/switch.blade.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - Checkbox - - - -use MoonShine\Fields\SwitchBoolean; - -//... -public function fields(): array -{ - return [ - SwitchBoolean::make('Publish', 'active') - ]; -} - -//... - - - -use MoonShine\Fields\SwitchBoolean; - -//... -public function fields(): array -{ - return [ - SwitchBoolean::make('Publish', 'active') - ->onValue(1) // Active value of a form element - ->offValue(0) // Inactive value of a form element - ]; -} - -//... - - - - -use MoonShine\Fields\SwitchBoolean; - -//... -public function fields(): array -{ - return [ - SwitchBoolean::make('Publish', 'active') - ->autoUpdate(false) // The option to change on the main page is disabled - ->autoUpdate(true) // The option to change on the home page is enabled - ->autoUpdate(fn() => true) - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/fields/text.blade.php b/resources/views/pages/en/fields/text.blade.php deleted file mode 100644 index b2497164..00000000 --- a/resources/views/pages/en/fields/text.blade.php +++ /dev/null @@ -1,83 +0,0 @@ - - - - The text field includes all the basic methods - - - -use MoonShine\Fields\Text; // [tl! focus] - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') // [tl! focus] - ]; -} - -//... - - - - - -Mask - - - Use the mask method if you want to add a mask to the field - - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - ->mask('7 (999) 999-99-99') // [tl! focus] - ]; -} - -//... - - - - - -Extensions - - -//... - -public function fields(): array -{ - return [ - Text::make('Title', 'title') - // Copy input value to clipboard - ->copy() - // Disable/enable input - ->locked() - // Expansion - ->expansion('kg') - // Switch type password/text - ->eye() - ]; -} - -//... - - - - - - - The copy method uses the Clipboard API which is only available for HTTPS or localhost - - - diff --git a/resources/views/pages/en/fields/textarea.blade.php b/resources/views/pages/en/fields/textarea.blade.php deleted file mode 100644 index 0ce86b06..00000000 --- a/resources/views/pages/en/fields/textarea.blade.php +++ /dev/null @@ -1,22 +0,0 @@ - - - - The Textarea field includes all the basic methods - - - -use MoonShine\Fields\Textarea; - -//... - -public function fields(): array -{ - return [ - Textarea::make('Label', 'table_field') - ]; -} - -//... - - - diff --git a/resources/views/pages/en/fields/url.blade.php b/resources/views/pages/en/fields/url.blade.php deleted file mode 100644 index 19e08df1..00000000 --- a/resources/views/pages/en/fields/url.blade.php +++ /dev/null @@ -1,17 +0,0 @@ - - - - Text - - - - Everything is the same as the "Text field", the only difference is input type = url - - - -use MoonShine\Fields\Url; - -Url::make('Url', 'url') - - - diff --git a/resources/views/pages/en/fields/wysiwyg.blade.php b/resources/views/pages/en/fields/wysiwyg.blade.php deleted file mode 100644 index 50b32541..00000000 --- a/resources/views/pages/en/fields/wysiwyg.blade.php +++ /dev/null @@ -1,209 +0,0 @@ - - - - Textarea - - -TinyMce - - -use MoonShine\Fields\TinyMce; // [tl! focus] - -//... -public function fields(): array -{ - return [ - TinyMce::make('Description', 'description'), // [tl! focus] - - // More advanced settings - - TinyMce::make('Text') // [tl! focus] - // Override the plugin set - ->plugins('anchor') // [tl! focus] - // Adding plugins to the base set - ->addPlugins('code codesample') // [tl! focus] - // Override the set toolbar - ->toolbar('undo redo | blocks fontfamily fontsize') // [tl! focus] - // Adding a toolbar to the base set - ->addToolbar('code codesample') // [tl! focus] - // To change the author name for a plugin tinycomments - ->commentAuthor('Danil Shutsky') // [tl! focus] - // Tags - ->mergeTags([ - ['value' => 'tag', 'title' => 'Title'] - ]) // [tl! focus:-2] - // Override the current locale - ->locale('en'), // [tl! focus] - ]; -} -//... - - - - Translation files are placed in the public/vendor/moonshine/libs/tinymce/langs directory - - - - - - - Sign up at Tiny.Cloud and get a token. Then add it to config/moonshine.php config - - - -//... -'tinymce' => [ - 'token' => 'YOUR_TOKEN' // [tl! focus] -] -//... - - -Laravel File manager -Laravel FileManager - - - If you want to use the file manager in tinymce, you need to install the Laravel FileManager package - - -Installing - - -composer require unisharp/laravel-filemanager - -php artisan vendor:publish --tag=lfm_config -php artisan vendor:publish --tag=lfm_public - - - - Be sure to set the 'use_package_routes' flag in the lfm config to false, otherwise the route caching will cause an error - - - -return [ - // ... - 'use_package_routes' => false, // [tl! focus] - // ... -]; - - - -Add routes to the app/Providers/RouteServiceProvider.php - - -// .. -Route::middleware('web') -->group(base_path('routes/web.php')); - -Route::group(['prefix' => 'laravel-filemanager', 'middleware' => ['moonshine', 'auth.moonshine']], function () { - UniSharp\LaravelFilemanager\Lfm::routes(); -}); // [tl! focus:-2] - -// .. - - - - The file manager route must be in the moonshine middleware group, not in the web! - - - - To allow access only to users authorized in the admin panel - middleware auth.moonshine must be used - - -Add the prefix to config/moonshine.php - - -//... -'tinymce' => [ - 'file_manager' => 'laravel-filemanager', // [tl! focus] - // ... -] -//... - - -Trix - - - This field belongs to a separate package, complete the installation before use - - - -composer require moonshine/trix - - - -use MoonShine\Fields\Trix; // [tl! focus] - -//... -public function fields(): array -{ - return [ - Trix::make('Description', 'description'), // [tl! focus] - ]; -} -//... - - - - - -CKEditor - - - The field is placed in a separate package, before use it is necessary to perform the installation - - - -composer require moonshine/ckeditor - - - -use MoonShine\CKEditor\Fields\CKEditor; // [tl! focus] - -//... -public function fields(): array -{ - return [ - CKEditor::make('Description', 'description'), // [tl! focus] - ]; -} -//... - - - - - -Quill - - - The field is placed in a separate package, before use it is necessary to perform the installation - - - - composer require moonshine/quill - - - -use MoonShine\Quill\Fields\Quill; // [tl! focus] - -//... -public function fields(): array -{ - return [ - Quill::make('Description', 'description'), // [tl! focus] - ]; -} -//... - - - - - - diff --git a/resources/views/pages/en/filters/belongs_to.blade.php b/resources/views/pages/en/filters/belongs_to.blade.php deleted file mode 100644 index 8e5ad172..00000000 --- a/resources/views/pages/en/filters/belongs_to.blade.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - BelongsTo - - - -use MoonShine\Filters\BelongsToFilter; - -//... - -public function filters(): array -{ - return [ - BelongsToFilter::make('Author', resource: 'name') - ->nullable() - ->canSee(fn() => auth('moonshine')->user()->moonshine_user_role_id === 1), - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/belongs_to_many.blade.php b/resources/views/pages/en/filters/belongs_to_many.blade.php deleted file mode 100644 index 4e2d1d22..00000000 --- a/resources/views/pages/en/filters/belongs_to_many.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - BelongsToMany - - - -use MoonShine\Filters\BelongsToManyFilter; - -//... - -public function filters(): array -{ - return [ - BelongsToManyFilter::make('Categories') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/date.blade.php b/resources/views/pages/en/filters/date.blade.php deleted file mode 100644 index e5cd68e9..00000000 --- a/resources/views/pages/en/filters/date.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - Date - - - -use MoonShine\Filters\DateFilter; - -//... - -public function filters(): array -{ - return [ - DateFilter::make('Created at') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/date_range.blade.php b/resources/views/pages/en/filters/date_range.blade.php deleted file mode 100644 index 8dfba5a5..00000000 --- a/resources/views/pages/en/filters/date_range.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - Date - - - -use MoonShine\Filters\DateRangeFilter; - -//... - -public function filters(): array -{ - return [ - DateRangeFilter::make('Created at') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/has_one.blade.php b/resources/views/pages/en/filters/has_one.blade.php deleted file mode 100644 index 7057730c..00000000 --- a/resources/views/pages/en/filters/has_one.blade.php +++ /dev/null @@ -1,26 +0,0 @@ - - - - HasOne - - - -use MoonShine\Filters\HasOneFilter; - -//... - -public function filters(): array -{ - return [ - HasOne::make('Phone', resource: 'number') - ->nullable() - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/index.blade.php b/resources/views/pages/en/filters/index.blade.php deleted file mode 100644 index d16eb115..00000000 --- a/resources/views/pages/en/filters/index.blade.php +++ /dev/null @@ -1,100 +0,0 @@ - - -Adding a filter - - - Fields - - - - Filters are shown on the main page of the resource to filter data. - They implement from the corresponding fields, so all methods of these fields are available here as well. - - - - Filters work in exactly the same way as fields, except that they are declared in the - filters resource method - - - -use MoonShine\Filters\BelongsToFilter; -use MoonShine\Filters\BelongsToManyFilter; -use MoonShine\Filters\DateRangeFilter; -use MoonShine\Filters\SlideFilter; -use MoonShine\Filters\SwitchBooleanFilter; -use MoonShine\Filters\TextFilter; - -//... - -public function filters(): array -{ - return [ - TextFilter::make('Title'), - - BelongsToFilter::make('Author', resource: 'name') - ->nullable() - ->canSee(fn() => auth('moonshine')->user()->moonshine_user_role_id === 1), - - TextFilter::make('Slug'), - - BelongsToManyFilter::make('Categories') - ->select(), - - DateRangeFilter::make('Created at'), - - SlideFilter::make('Age') - ->fromField('age_from') - ->toField('age_to') - ->min(0) - ->max(60), - - SwitchBooleanFilter::make('Active') - ]; -} - -//... - - - - - -Custom query - - - Using the customQuery method, you can create a custom query for the filter - - - -use MoonShine\Filters\DateRangeFilter; -use MoonShine\Filters\TextFilter; - -//... - -public function filters(): array -{ - return [ - TextFilter::make('Title') - ->customQuery(fn(Builder $query, $value) => $query->where('title', 'LIKE', "%${value}%")), // [tl! focus] - - DateRangeFilter::make('Created at') - ->customQuery(function (Builder $query, $values) { - return $query - ->when($values['from'] ?? null, function ($query, $fromDate) { - $query->whereDate('created_at', '>=', Carbon::parse($fromDate)); - }) - ->when($values['to'] ?? null, function ($query, $toDate) { - $query->whereDate('created_at', '<=', Carbon::parse($toDate)); - }); - }), // [tl! focus] - ]; -} - -//... - - - diff --git a/resources/views/pages/en/filters/is_empty.blade.php b/resources/views/pages/en/filters/is_empty.blade.php deleted file mode 100644 index bdb8ce14..00000000 --- a/resources/views/pages/en/filters/is_empty.blade.php +++ /dev/null @@ -1,32 +0,0 @@ - - - - SwitchBooleanFilter - - -Enables displaying only rows with empty (not empty for IsNotEmptyFilter) field values - -Empty values are the following: - - - -use MoonShine\Filters\IsEmptyFilter; -use MoonShine\Filters\IsNotEmptyFilter; - -//... - -public function filters(): array -{ - return [ - IsEmptyFilter::make('Url'), - IsNotEmptyFilter::make('Active') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/select.blade.php b/resources/views/pages/en/filters/select.blade.php deleted file mode 100644 index 23858932..00000000 --- a/resources/views/pages/en/filters/select.blade.php +++ /dev/null @@ -1,29 +0,0 @@ - - - - Select - - - -use MoonShine\Filters\SelectFilter; - -//... - -public function filters(): array -{ - return [ - SelectFilter::make('Country', 'country_id') - ->options([ - 'value 1' => 'Option Label 1', - 'value 2' => 'Option Label 2' - ]) - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/slide.blade.php b/resources/views/pages/en/filters/slide.blade.php deleted file mode 100644 index 4714e0d5..00000000 --- a/resources/views/pages/en/filters/slide.blade.php +++ /dev/null @@ -1,29 +0,0 @@ - - - - Slide - - - -use MoonShine\Filters\SlideFilter; - -//... - -public function filters(): array -{ - return [ - SlideFilter::make('Age') - ->fromField('age_from') - ->toField('age_to') - ->min(0) - ->max(60) - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/switch.blade.php b/resources/views/pages/en/filters/switch.blade.php deleted file mode 100644 index 58d08f00..00000000 --- a/resources/views/pages/en/filters/switch.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - Switch - - - -use MoonShine\Filters\SwitchBooleanFilter; - -//... - -public function filters(): array -{ - return [ - SwitchBooleanFilter::make('Active') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/filters/text.blade.php b/resources/views/pages/en/filters/text.blade.php deleted file mode 100644 index e2118f48..00000000 --- a/resources/views/pages/en/filters/text.blade.php +++ /dev/null @@ -1,25 +0,0 @@ - - - - Text - - - -use MoonShine\Filters\TextFilter; - -//... - -public function filters(): array -{ - return [ - TextFilter::make('Title') - ]; -} - -//... - - - - - - diff --git a/resources/views/pages/en/home.blade.php b/resources/views/pages/en/home.blade.php deleted file mode 100644 index 76898a1e..00000000 --- a/resources/views/pages/en/home.blade.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Hello Laravel user! - - - Welcome to the open-source project dedicated to the "MoonShine" admin panel. - - - I've been working on it for several years and have used it on dozens of small projects constantly tweaking it. - - - What does moonshine mean? It's not exactly "moonlight" - my idea is the "moonshine" concept. - The term means the independent production of a drink in illegal conditions under the cover of the night :) - So I developed this admin panel at night in my free time under the moonlight ;) - - - Everything is already ready for use in your projects, - documentation has been created describing the installation, configuration and features. - - - I invite interested users to use and develop Moonshine together. - - - - - diff --git a/resources/views/pages/en/icons/heroicons.blade.php b/resources/views/pages/en/icons/heroicons.blade.php deleted file mode 100644 index de8eba9e..00000000 --- a/resources/views/pages/en/icons/heroicons.blade.php +++ /dev/null @@ -1,37 +0,0 @@ - - - - In addition to the standard icons, you can find preinstalled - icons from the Heroicons collection - (Solid set is the default one, plus Outline) in the resources/views/vendor/moonshine/shared/icons/heroicons folder. - You can use them wherever you use the icon() method - - -Solid - - - ->icon('heroicons.academic-cap') // [tl! focus] - - - - -Outline - - - ->icon('heroicons.outline.academic-cap') // [tl! focus] - - - - - diff --git a/resources/views/pages/en/icons/index.blade.php b/resources/views/pages/en/icons/index.blade.php deleted file mode 100644 index 25d4c877..00000000 --- a/resources/views/pages/en/icons/index.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - For all entities that have the icon() method, - you can use one of the proposed icon sets or create your own set - - -System icons - - - ->icon('add') // [tl! focus] - - - - -Custom icons - - - You can also create a blade file with your custom icon. To do this you have to create a blade file in - resources/views/vendor/moonshine/shared/icons (e.g. - my-icon.blade.php) containing the icon image inside (e.g. svg code) - and then specify the icon('my-icon') - - - diff --git a/resources/views/pages/en/installation.blade.php b/resources/views/pages/en/installation.blade.php deleted file mode 100644 index 7c6c690e..00000000 --- a/resources/views/pages/en/installation.blade.php +++ /dev/null @@ -1,99 +0,0 @@ - - -Requirements - - - To use MoonShine, the following requirements must be met prior to installation: - - - -Composer - - - composer require moonshine/moonshine:2.0.0.alpha.1 - - -Installation - - - php artisan moonshine:install - - - - This command will add config/moonshine.php with the basic settings. - More about the config file - - - - A directory containing the admin panel and resources will also be added - app/MoonShine. - More about Resources - - - - It will also add MoonShineServiceProvider App\Providers\MoonShineServiceProvider where you need to register resources. - More about Resources - - - - Create an Administrator - - - - php artisan moonshine:user - - - - Resource registration and menu configuration - - - - To register new resources in the MoonShine and configure a menu, we need app/Providers/MoonShineServiceProvider.php - - - -namespace App\Providers; - -use Illuminate\Support\ServiceProvider; -use MoonShine\MoonShine; -use MoonShine\Menu\MenuItem; -use MoonShine\Resources\MoonShineUserResource; - -class MoonShineServiceProvider extends ServiceProvider -{ - public function boot(): void - { - // [tl! focus:start] - app(MoonShine::class)->menu([ - MenuItem::make('Admins', new MoonShineUserResource()), - ]); - // [tl! focus:end] - } -} - - - - In this example, we have added a menu item with panel admins. - More about Menu - - - - Great! Now you can create and register sections of the future admin panel and proceed with the real work! - But don't forget to read the documentation all the way through! - - - - By default, the admin panel is accessed by url /moonshine. You can change the url in - config file. - - - diff --git a/resources/views/pages/en/metrics/donut_chart.blade.php b/resources/views/pages/en/metrics/donut_chart.blade.php deleted file mode 100644 index 4c9034e6..00000000 --- a/resources/views/pages/en/metrics/donut_chart.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - Provides the ability to create a donut chart for metric - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\DonutChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - DonutChartMetric::make('Subscribers') - ->values(['CutCode' => 10000, 'Apple' => 9999]), - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/metrics/index.blade.php b/resources/views/pages/en/metrics/index.blade.php deleted file mode 100644 index 33a266ea..00000000 --- a/resources/views/pages/en/metrics/index.blade.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - These blocks are intended for displaying statistics - - - - You can show them on the admin panel home page - and in every individual resource as well - - - - Metrics are also provided with - Layout (columnSpan) decorator features - - diff --git a/resources/views/pages/en/metrics/line_chart.blade.php b/resources/views/pages/en/metrics/line_chart.blade.php deleted file mode 100644 index 0872fb56..00000000 --- a/resources/views/pages/en/metrics/line_chart.blade.php +++ /dev/null @@ -1,99 +0,0 @@ - - - - Provides the ability to create a line chart for metric - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\LineChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray() - ]) - ->line([ - 'Avg' => Order::query() - ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('avg','date') - ->toArray() - ], '#EC4176'), - ]; - } // [tl! focus:end] - - //... -} - - - - or using one line method - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\LineChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray(), - 'Avg' => Order::query() - ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('avg','date') - ->toArray() - ],[ - 'red', 'blue' - ]) - ]; - } // [tl! focus:end] - - //... -} - - - - - - - By default, LineChart graphics sort keys in ascending order. - This feature can be used with the usual withoutSortKeys() method. - - - -LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray() - ]) - ->withoutSortKeys(), // [tl! focus] - - - diff --git a/resources/views/pages/en/metrics/value.blade.php b/resources/views/pages/en/metrics/value.blade.php deleted file mode 100644 index ce30ff2d..00000000 --- a/resources/views/pages/en/metrics/value.blade.php +++ /dev/null @@ -1,89 +0,0 @@ - - - - Displays a simple value, such as how many specific records a table contains - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Completed orders') - ->value(Orders::completed()->count()) - ]; - } // [tl! focus:end] - - //... -} - - - - - - - You can also display a value as a goal progress indicator - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Open orders left') - ->value(Orders::completed()->count()) - ->progress(200) // Ultimate goal - ]; - } // [tl! focus:end] - - //... -} - - - - - - - You can add formatting, prefix, and suffix to the output value - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Revenue') - ->value(Orders::completed()->sum('price')) - ->valueFormat('for today {value} rub.') - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/packages.blade.php b/resources/views/pages/en/packages.blade.php deleted file mode 100644 index ca325aff..00000000 --- a/resources/views/pages/en/packages.blade.php +++ /dev/null @@ -1,3 +0,0 @@ - - @include('packages') - diff --git a/resources/views/pages/en/releases.blade.php b/resources/views/pages/en/releases.blade.php deleted file mode 100644 index e57a14e4..00000000 --- a/resources/views/pages/en/releases.blade.php +++ /dev/null @@ -1,272 +0,0 @@ - - -
-
diff --git a/resources/views/pages/en/resources/actions.blade.php b/resources/views/pages/en/resources/actions.blade.php deleted file mode 100644 index 8477bff3..00000000 --- a/resources/views/pages/en/resources/actions.blade.php +++ /dev/null @@ -1,54 +0,0 @@ - - -Basics - - - Often it is necessary to do something with the list of the section and "Actions" serve for this purpose. - At the moment, there is only one Action class in MoonShine, which is responsible for exporting data, - but actions could be extended and you can easily write your own. - - - - You can simply return all the necessary actions in the actions method which returns an array. - And we will talk about actions structure in the "Actions" section. - - - - If the method is absent or returns an empty array, then the actions will not be displayed - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\Actions\ExportAction; // [tl! focus] - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function actions(): array // [tl! focus:start] - { - return [ - ExportAction::make('Export') - ]; - } // [tl! focus:end] - - //... -} - - - - - -@include('pages.en.resources.shared.actions_view', ['action' => 'ExportAction']) - - diff --git a/resources/views/pages/en/resources/active_actions.blade.php b/resources/views/pages/en/resources/active_actions.blade.php deleted file mode 100644 index 514fe339..00000000 --- a/resources/views/pages/en/resources/active_actions.blade.php +++ /dev/null @@ -1,55 +0,0 @@ - - - - Quite often you need to create a resource with the disabled delete - or add or edit section. And we are not talking about authorization here, but about the global exclusion of these sections. - This could be done very easy by using the activeActions property in the resource - - - -namespace MoonShine\Resources; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - - public static array $activeActions = ['create', 'show', 'edit', 'delete']; // [tl! focus] - //... -} - - -Just eliminate the needless one - - - public static array $activeActions = ['create']; // [tl! focus] - - -You can also use the getActiveActions() method and set your own logic for the available sections - - -namespace MoonShine\Resources; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - - public static array $activeActions = ['create', 'show', 'edit']; // [tl! focus] - - //... - - public function getActiveActions(): array // [tl! focus:start] - { - if (auth()->id() === $this->getItem()?->author_id) { - return array_merge(static::$activeActions, ['delete']); - } - - return static::$activeActions; - } // [tl! focus:end] -} - - - diff --git a/resources/views/pages/en/resources/bulk_actions.blade.php b/resources/views/pages/en/resources/bulk_actions.blade.php deleted file mode 100644 index 3289cd5a..00000000 --- a/resources/views/pages/en/resources/bulk_actions.blade.php +++ /dev/null @@ -1,48 +0,0 @@ - - - - By default, the table in the MoonShine panel contains only 1 mass action for the elements - deletion. - But you can also add your own custom bulk actions - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\BulkActions\BulkAction; // [tl! focus] - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function bulkActions(): array // [tl! focus:start] - { - return [ - BulkAction::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated')->icon('app') - ]; - } // [tl! focus:end] - - //... -} - - -

- The first argument is the name of the action. - The second argument is a callback with the current element parameter. - The third argument is the message that will be displayed after the execution of the action. -

- -@include('pages.en.resources.shared.actions_view', ['action' => 'BulkAction']) -@include('pages.en.resources.shared.actions_confirm', ['action' => 'BulkAction']) - -
diff --git a/resources/views/pages/en/resources/components.blade.php b/resources/views/pages/en/resources/components.blade.php deleted file mode 100644 index fc312ccd..00000000 --- a/resources/views/pages/en/resources/components.blade.php +++ /dev/null @@ -1,133 +0,0 @@ - - -Basics - - - You can add your own components based on the MoonShine\IndexComponent, MoonShine\FormComponent - or MoonShine\DetailComponent abstract classes to extend the functionality, - they will be displayed below the main form or below detailed information respectively - - - - All custom components must be registered in the components() method - - - -namespace MoonShine\Resources; - -class ArticleResource extends Resource -{ - //... - - public function components(): array // [tl! focus:2] - { - return [ - // ... - ]; - } // [tl! focus:-1] - - //... -} - - -Permissions - - - Example of adding a PermissionFormComponent component - - - -namespace MoonShine\Resources; - -use MoonShine\FormComponents\PermissionFormComponent; // [tl! focus] -use MoonShine\Models\MoonshineUserRole; -use MoonShine\Resources\Resource; - -class MoonShineUserResource extends Resource -{ - //... - - public function components(): array - { - return [ - PermissionFormComponent::make('Permissions') // [tl! focus] - ->canSee(fn() => auth()->user()->moonshine_user_role_id === MoonshineUserRole::DEFAULT_ROLE_ID) - ]; - } - - //... -} - - - - - - - If you use your model for authentication, - then you need to add the MoonShine\Traits\Models\HasMoonShinePermissions trait to it - - - - If you use your resource with admin output, - you need to add the MoonShine\Traits\Resource\WithUserPermissions trait to the resource - - -Change log - - - To display the log of edits in the admin panel based on the user you must add - the MoonShine\Traits\Models\HasMoonShineChangeLog trait to the model being used in the resource - - - -namespace App\Models; - -use Illuminate\Database\Eloquent\Model; -use MoonShine\Traits\Models\HasMoonShineChangeLog; // [tl! focus] - -class Article extends Model -{ - use HasMoonShineChangeLog; // [tl! focus] - - //... -} - - - - And also add a component in the ChangeLogFormComponent resource - - - -namespace MoonShine\Resources; - -use MoonShine\FormComponents\ChangeLogFormComponent; // [tl! focus] -use MoonShine\Models\MoonshineUserRole; -use MoonShine\Resources\Resource; - -class ArticleResource extends Resource -{ - // ... - public function components(): array - { - return [ - ChangeLogFormComponent::make('Change log') // [tl! focus] - ->canSee(fn() => auth()->user()->moonshine_user_role_id === MoonshineUserRole::DEFAULT_ROLE_ID), - ]; - } - // ... -} - - - - - - diff --git a/resources/views/pages/en/resources/fields.blade.php b/resources/views/pages/en/resources/fields.blade.php deleted file mode 100644 index 93169f67..00000000 --- a/resources/views/pages/en/resources/fields.blade.php +++ /dev/null @@ -1,49 +0,0 @@ - - - - Fields in most cases refer to table fields from the database. Within CRUD they will be displayed - with a list on the main page of the section (resource) and on the page for creating and editing records. - There are many types of fields in the MoonShine admin panel to cover all possible requirements! - They also cover all possible relationships in Laravel and are named in the same way as relationship methods for convenience: - BelongsTo, BelongsToMany, HasOne, HasMany, - HasOneThrough, HasManyThrough, MorphOne, MorphMany - - - - Adding new fields is extremely easy! You can simply return all the required fields in the fields method which returns an array. - And we will talk about fields structure in the "Fields" section. - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\Fields\ID; // [tl! focus] -use MoonShine\Fields\Text; // [tl! focus] -use MoonShine\Decorations\Block; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function fields(): array // [tl! focus:start] - { - return [ - Block::make('Block title', [ - ID::make(), - Text::make('header', 'title'), - ]) - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/resources/filters.blade.php b/resources/views/pages/en/resources/filters.blade.php deleted file mode 100644 index 0472dbe7..00000000 --- a/resources/views/pages/en/resources/filters.blade.php +++ /dev/null @@ -1,55 +0,0 @@ - - - - Filters are not much different from fields and inherit their properties and methods! - They are displayed on the main page of the section to filter the list of data. - - - - Adding new filters is easy! You can simply return all the necessary filters in the filters method which returns an array. - And we will talk about filters structure in the "Filters" section. - - - - If the method is absent or returns an empty array, then the filters will not be displayed - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\Filters\TextFilter; // [tl! focus] - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - // [tl! focus:start] - public function filters(): array - { - return [ - TextFilter::make('header', 'title') - ]; - } - - // Don't forget to connect filters to the resource - public function actions(): array - { - return [ - FiltersAction::make(trans('moonshine::ui.filters')), - ]; - } - - // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/resources/form_actions.blade.php b/resources/views/pages/en/resources/form_actions.blade.php deleted file mode 100644 index 1faf37e1..00000000 --- a/resources/views/pages/en/resources/form_actions.blade.php +++ /dev/null @@ -1,45 +0,0 @@ - - - - By default, forms in the MoonShine panel contain only 1 action - saving. - But you can add your own custom actions - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\FormActions\FormAction; // [tl! focus] - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function formActions(): array // [tl! focus:start] - { - return [ - FormAction::make('Delete', function (Model $item) { - $item->delete(); - }, 'Removed')->icon('delete') - ]; - } // [tl! focus:end] - - //... -} - - - - - -@include('pages.en.resources.shared.actions_view', ['action' => 'FormAction']) -@include('pages.en.resources.shared.actions_confirm', ['action' => 'FormAction']) - - diff --git a/resources/views/pages/en/resources/index.blade.php b/resources/views/pages/en/resources/index.blade.php deleted file mode 100644 index 4220fcee..00000000 --- a/resources/views/pages/en/resources/index.blade.php +++ /dev/null @@ -1,370 +0,0 @@ - - -Basics - - - What is an administrative panel? Basically, these are partitions based on data from the database, based on eloquent models. - - - - MoonShine is based on standard Laravel resource controllers and resource routes - - - php artisan make:controller Controller --resource - - - - Route::resources('resources', Controller::class); - - - But system will generate and declare them independently. - - - - Therefore, the MoonShine resources (admin panel sections) are based on the eloquent model. - - -Creating a section in the admin panel - - - php artisan moonshine:resource Post - - - - This will create a Resource class that will be the basis of the new section in the panel. - By default, it is located in the app/MoonShine/Resources/PostResource directory. - And it will be automatically bound to the app/Models/Post model. - The section title will keep the Posts name - - - - You can change the model binding and section title along with the command - - - php artisan moonshine:resource Post --model=CustomPost --title="Articles" - - - - php artisan moonshine:resource Post --model="App\Models\CustomPost" --title="Articles" - - - -Main properties of the section - - The main parameters of the resource that could be changed in order to customize its work - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; // Model [tl! focus] - - public static string $title = 'Articles'; // Section name [tl! focus] - - public static string $subTitle = 'Article Management'; // Text under section heading [tl! focus] - - public static array $with = ['category']; // Eager load [tl! focus] - - public static bool $withPolicy = false; // Authorization [tl! focus] - - public static string $orderField = 'id'; // Default sort field [tl! focus] - - public static string $orderType = 'DESC'; // Default sort type [tl! focus] - - public static int $itemsPerPage = 25; // Number of items per page [tl! focus] - - //... -} - - - - - -Declaring a partition in the system - - - New resources are added to the system in the service provider using the singleton class - MoonShine\MoonShine. - - - -namespace App\Providers; - -use App\MoonShine\Resources\PostResource; // [tl! focus] - -class MoonShineServiceProvider extends ServiceProvider -{ - //... - - public function boot() - { - app(MoonShine::class)->resources([ - new PostResource(), - ]) // [tl! focus: -2] - } - - - - To add a resource link to the navigation menu, the resource can be registered using the menu() method. - - - -namespace App\Providers; - -use App\MoonShine\Resources\PostResource; // [tl! focus] -use Illuminate\Support\ServiceProvider; -use MoonShine\Menu\MenuItem; // [tl! focus] -use MoonShine\MoonShine; // [tl! focus] -use MoonShine\Resources\MoonShineUserResource; -use MoonShine\Resources\MoonShineUserRoleResource; - -class MoonShineServiceProvider extends ServiceProvider -{ - //... - - public function boot() - { - app(MoonShine::class)->menu([ // [tl! focus] - MenuItem::make('Admins', new MoonShineUserResource()), - MenuItem::make('Roles', new MoonShineUserRoleResource()), - MenuItem::make('Posts', new PostResource()), // [tl! focus] - ]); // [tl! focus] - } -} - - - - - - - For advanced settings, see Digging Deeper > Menu. - - -Current item/model - - - In the resource you have access to the current element and model via the relevant methods. - - - - $this->getItem(); - - - - $this->getModel(); - - - - If the element does not yet exist (action create), then the getItem() method will return NULL. - - -Modal windows - - - Ability to add, edit and view entries directly on the list page in a modal window. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; - -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - public static string $title = 'Posts'; - - protected bool $createInModal = true; // [tl! focus] - - protected bool $editInModal = true; // [tl! focus] - - protected bool $showInModal = true; // [tl! focus] - - // ... - - -Route after save - - - After saving the resource, you can specify which route to go to: - the list page, the detail page, or the edit page. - - -Default index - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - protected string $routeAfterSave = 'index'; // index, show, edit [tl! focus] - - // ... -} - - -Simple pagination - - - If you don't plan to display the total number of pages, use Simple Pagination. - This will avoid additional queries on the total number of records in the database. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - public static bool $simplePaginate = true; // [tl! focus] - - // ... -} - - - - - -Disable pagination - - - If you do not plan to use pagination, then you can turn it off. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - protected bool $usePagination = false; // [tl! focus] - - // ... -} - - -Customization of views - - - You can customize the display of the list and form through - the properties itemsView, formView and detailView. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - protected string $itemsView = 'moonshine::crud.shared.table'; // [tl! focus] - - protected string $formView = 'moonshine::crud.shared.form'; // [tl! focus] - - protected string $detailView = 'moonshine::crud.shared.detail-card'; // [tl! focus] - - // ... -} - - - - Or by overriding the appropriate methods - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - public function itemsView(): string - { - return $this->itemsView; - } // [tl! focus:-3] - - public function formView(): string - { - return $this->formView; - } // [tl! focus:-3] - - public function detailView(): string - { - return $this->detailView; - } // [tl! focus:-3] - - // ... -} - - -Precognition - - - Precognition in Laravel allows you to create a "live" check for your application - without having to duplicate validation rules. - - - - In Moonshine, you can use precognition when sending requests to your resource. - To do this, set the precognition property to true. - - - -namespace App\MoonShine\Resources; - -use App\Models\Post; -use MoonShine\Resources\Resource; - -class PostResource extends Resource -{ - public static string $model = Post::class; - - protected bool $precognition = true; // [tl! focus] - - // ... -} - - - diff --git a/resources/views/pages/en/resources/item_actions.blade.php b/resources/views/pages/en/resources/item_actions.blade.php deleted file mode 100644 index 1ad60045..00000000 --- a/resources/views/pages/en/resources/item_actions.blade.php +++ /dev/null @@ -1,72 +0,0 @@ - - -Registration - - - By default, the table in the MoonShine panel contains only 2 actions for items - edit and delete. - But you can also add your own custom actions - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\ItemActions\ItemAction; // [tl! focus] - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function itemActions(): array // [tl! focus:start] - { - return [ - ItemAction::make('Deactivating', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated')->icon('app') - ]; - } // [tl! focus:end] - - //... -} - - -

- The first argument is the name of the action. - The second argument is the callback with the current item parameter. - The third argument - the message that will be displayed after the action is executed -

- -Display condition - - - Display action by condition - - - -... -public function itemActions(): array -{ - return [ - ItemAction::make('Restore', function (Model $item) { - $item->restore(); - }, 'Retrieved') - ->canSee(fn(Model $item) => $item->trashed()) // [tl! focus] - ]; -} -... - - -@include('pages.en.resources.shared.actions_view', ['action' => 'ItemAction']) -@include('pages.en.resources.shared.actions_confirm', ['action' => 'ItemAction']) - -
diff --git a/resources/views/pages/en/resources/metrics.blade.php b/resources/views/pages/en/resources/metrics.blade.php deleted file mode 100644 index 0de98cb5..00000000 --- a/resources/views/pages/en/resources/metrics.blade.php +++ /dev/null @@ -1,33 +0,0 @@ - - - - Same as the control panel you can - display metrics in every resource - - - -namespace MoonShine\Resources; - - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Completed orders') - ->value(Orders::completed()->count()) - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/resources/query.blade.php b/resources/views/pages/en/resources/query.blade.php deleted file mode 100644 index e4d062da..00000000 --- a/resources/views/pages/en/resources/query.blade.php +++ /dev/null @@ -1,93 +0,0 @@ - - -Filter - - - Quite often you have to filter the output with a list of records from the very start. - - - - In general, you can easily override the query builder in the resource. - - - -namespace MoonShine\Resources; - -use Illuminate\Contracts\Database\Eloquent\Builder; // [tl! focus] - -class PostResource extends Resource -{ - //... - public function query(): Builder // [tl! focus:start] - { - return parent::query() - ->where('active', true); - } // [tl! focus:end] - //... -} - - -Order - - - By overriding the performOrder() method, you can customize the sorting of elements. - - - -namespace MoonShine\Resources; - -use Illuminate\Contracts\Database\Eloquent\Builder; // [tl! focus] - -class PostResource extends Resource -{ - //... - public function performOrder(Builder $query, string $column, string $direction): Builder // [tl! focus:start] - { - return $query->orderBy( - $column, - $direction - ); - } // [tl! focus:end] - //... -} - - -Scopes - - - Laravel has a handy scopes functionality that could be used within the MoonShine admin panel. - - - - At first, you need to create the scopes required. - - - -php artisan make:scope ActiveUserScope - - - -namespace MoonShine\Resources; - -use App\Models\Scopes\ActiveUserScope; // [tl! focus] - -class PostResource extends Resource -{ - //... - public function scopes(): array // [tl! focus:start] - { - return [ - new ActiveUserScope() - ]; - } // [tl! focus:end] - //... -} - - - diff --git a/resources/views/pages/en/resources/query_tags.blade.php b/resources/views/pages/en/resources/query_tags.blade.php deleted file mode 100644 index ae18b55e..00000000 --- a/resources/views/pages/en/resources/query_tags.blade.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - Sometimes you may need to create a set of filters (collection of results) - and display it in the listing. Tags have been created for these cases. - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; -use MoonShine\QueryTags\QueryTag; // [tl! focus] -use Illuminate\Contracts\Database\Eloquent\Builder; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function queryTags(): array // [tl! focus:start] - { - return [ - QueryTag::make( - 'Post with author', // Tag Title - fn(Builder $query) => $query->whereNotNull('author_id') // Query builder - ), - - QueryTag::make( - 'Post without an author', - fn(Builder $query) => $query->whereNull('author_id') - )->icon('users') - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/en/resources/search.blade.php b/resources/views/pages/en/resources/search.blade.php deleted file mode 100644 index c46ce92e..00000000 --- a/resources/views/pages/en/resources/search.blade.php +++ /dev/null @@ -1,79 +0,0 @@ - - -Основы - - - Everything is simple here! For a full-text search, you need to specify which fields will be included into the search. - To do this, you need to list them in the return array in the search() method - - - - If the method is missing or returns an empty array, the search string will not be displayed - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ - //... - - public function search(): array // [tl! focus:start] - { - return ['id', 'title']; - } // [tl! focus:end] - - //... -} - - - - If a fulltext search is required, you must use the MoonShine\Attributes\SearchUsingFullText - - - - namespace MoonShine\Resources; - - use MoonShine\Attributes\SearchUsingFullText; // [tl! focus] - - class PostResource extends Resource - { - //... - - #[SearchUsingFullText(['title', 'text'])] // [tl! focus] - public function search(): array - { - return ['id']; - } - - //... - } - - - - Don't forget to add the fulltext index - - - - - -Global search - - - To organize a global search, you can use the package - Algolias search for MoonShine - - - - This package uses the Algolia search engine, which takes context and query type into account, - possible typos, synonyms and word forms, entering a query in different languages and much more. - - - diff --git a/resources/views/pages/en/resources/shared/actions_confirm.blade.php b/resources/views/pages/en/resources/shared/actions_confirm.blade.php deleted file mode 100644 index 45b14f46..00000000 --- a/resources/views/pages/en/resources/shared/actions_confirm.blade.php +++ /dev/null @@ -1,78 +0,0 @@ -Confirm the action - - - To confirm the action, you must use the withConfirm method - - - -use MoonShine\{!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'Action' : $action !!}s\{{ $action }}; - -//... -public function {!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'action' : str($action)->camel() !!}s(): array -{ - return [ - @if ( $action === 'ExportAction' || $action === 'ImportAction') - {!! $action !!}::make('{!! str($action)->replace('Action', '') !!}') - @else - {{ $action }}::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated') - @endif - ->withConfirm() // [tl! focus] - ]; -} -//... - - - - - - - The withConfirm() method can be passed the title and text for the modal window, as well as the title - for confirmation button - - - -use MoonShine\{!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'Action' : $action !!}s\{{ $action }}; - -//... -public function {!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'action' : str($action)->camel() !!}s(): array -{ - return [ - @if ( $action === 'ExportAction' || $action === 'ImportAction') - {!! $action !!}::make('{!! str($action)->replace('Action', '') !!}') - @else - {{ $action }}::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated') - @endif - ->withConfirm('Title', 'Modal content', 'Accept') // [tl! focus] - ]; -} -//... - - - - The errorMessage() method allows you to set the text of the error message - - - -use MoonShine\{!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'Action' : $action !!}s\{{ $action }}; - -//... -public function {!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'action' : str($action)->camel() !!}s(): array -{ - return [ - @if ( $action === 'ExportAction' || $action === 'ImportAction') - {!! $action !!}::make('{!! str($action)->replace('Action', '') !!}') - @else - {{ $action }}::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated') - @endif - ->withConfirm('Title', 'Modal content', 'Accept') - ->errorMessage('Fail') // [tl! focus] - ]; -} -//... - diff --git a/resources/views/pages/en/resources/shared/actions_view.blade.php b/resources/views/pages/en/resources/shared/actions_view.blade.php deleted file mode 100644 index ef2448da..00000000 --- a/resources/views/pages/en/resources/shared/actions_view.blade.php +++ /dev/null @@ -1,59 +0,0 @@ -Display method - - - To display actions as a dropdown list, you can use the showInDropdown method - - - -use MoonShine\{!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'Action' : $action !!}s\{{ $action }}; - -//... -public function {!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'action' : str($action)->camel() !!}s(): array -{ - return [ - @if ( $action === 'ExportAction' || $action === 'ImportAction') - {!! $action !!}::make('{!! str($action)->replace('Action', '') !!}') - @else - {{ $action }}::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated') - @endif - ->showInDropdown() // [tl! focus] - ]; -} -//... - - - - This display method is used by default - - - - - - - To display actions as a horizontal list, you can use the showInLine method - - - -use MoonShine\{!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'Action' : $action !!}s\{{ $action }}; - -//... -public function {!! ($action === 'ExportAction' || $action === 'ImportAction') ? 'action' : str($action)->camel() !!}s(): array -{ - return [ - @if ( $action === 'ExportAction' || $action === 'ImportAction') - {!! $action !!}::make('{!! str($action)->replace('Action', '') !!}') - @else - {{ $action }}::make('Deactivation', function (Model $item) { - $item->update(['active' => false]); - }, 'Deactivated') - @endif - ->showInLine() // [tl! focus] - ]; -} -//... - - - - diff --git a/resources/views/pages/en/resources/singleton.blade.php b/resources/views/pages/en/resources/singleton.blade.php deleted file mode 100644 index 5dc97dd1..00000000 --- a/resources/views/pages/en/resources/singleton.blade.php +++ /dev/null @@ -1,52 +0,0 @@ - - - - A resource for one entry without the ability to list, add and delete! Perfect for resources with settings. - Implements singletonResource in Laravel routing. - - - - To use it, you need to implement the getId method specifying the id of the record in the database. - - - -// ... - -class SettingResource extends SingletonResource -{ - public static string $model = Setting::class; - - public static string $title = 'Settings'; - - public function getId(): int|string - { - return 1; - } -// ... - - - - You can create SingletonResource using the artisan command - - - - php artisan moonshine:resource Setting --singleton - - - - or - - - - php artisan moonshine:resource Setting --s - - - - with id - - - - php artisan moonshine:resource Setting --s --id=1 - - - diff --git a/resources/views/pages/en/resources/table_styles.blade.php b/resources/views/pages/en/resources/table_styles.blade.php deleted file mode 100644 index 28655c0e..00000000 --- a/resources/views/pages/en/resources/table_styles.blade.php +++ /dev/null @@ -1,81 +0,0 @@ - - - - Using resources you can customize the color for tr and td for tables with data - - - -namespace MoonShine\Resources; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function trClass(Model $item, int $index): string // [tl! focus:start] - { - if($item->id === 1 || $index === 2) { - return 'green'; - } - - return parent::trClass($item, $index); - } - - public function tdClass(Model $item, int $index, int $cell): string - { - if($cell === 6) { - return 'red'; - } - - return parent::tdClass($item, $index, $cell); - } // [tl! focus:end] - //... -} - - -@include('pages.en.components.shared.colors') - - - - - - You can also add custom styles - - - -namespace MoonShine\Resources; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function trStyles(Model $item, int $index): string // [tl! focus:start] - { - if ($item->id === 1 || $index === 2) { - return 'background: rgba(128, 152, 253, .5);'; - } - - return parent::trStyles($item, $index); - } - - public function tdStyles(Model $item, int $index, int $cell): string - { - if ($cell === 3) { - return 'background: rgba(128, 253, 163, .5); text-align:center;'; - } - - return parent::tdStyles($item, $index, $cell); - } // [tl! focus:end] - //... -} - - - - - - diff --git a/resources/views/pages/en/resources/validation.blade.php b/resources/views/pages/en/resources/validation.blade.php deleted file mode 100644 index 3a669777..00000000 --- a/resources/views/pages/en/resources/validation.blade.php +++ /dev/null @@ -1,103 +0,0 @@ - - -Basics - - - Validation is as simple as in the FormRequests classes provided by Laravel. - - - - You can simply add rules to the rules() method of the resource in the usual way. - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - - public static string $title = 'Articles'; - //... - - public function rules($item): array // [tl! focus:start] - { - return [ - 'title' => ['required', 'string', 'min:5'] - ]; - } // [tl! focus:end] - - //... -} - - - - - -Messages - - - Using the validationMessages() method, you can create your own validation error messages - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - //... - - public function validationMessages(): array // [tl! focus:start] - { - return [ - 'email.required' => 'Required email' - ]; - } // [tl! focus:end] - - //... -} - - -Preparing Input For Validation - - - If you need to prepare or sanitize any data from the request before you apply your validation rules, - you may use the prepareForValidation() method. - - - -namespace MoonShine\Resources; - -use MoonShine\Models\MoonshineUser; - -class PostResource extends Resource -{ - public static string $model = App\Models\Post::class; - //... - - public function prepareForValidation(): void // [tl! focus:start] - { - request()?->merge([ - 'email' => request() - ?->string('email') - ->lower() - ->value() - ]); - } // [tl! focus:end] - - //... -} - - - diff --git a/resources/views/pages/en/upgrade_guide.blade.php b/resources/views/pages/en/upgrade_guide.blade.php deleted file mode 100644 index ebb06fda..00000000 --- a/resources/views/pages/en/upgrade_guide.blade.php +++ /dev/null @@ -1,38 +0,0 @@ - - - - Upgrading To 1.50 From 1.0 - - - - registerResources is outdated and will be removed in 2.0 version - - - -app(MoonShine::class)->registerResources([ - MenuItem::make('Admins', new MoonShineUserResource()), -]); - - - - We recommend to use the menu method - - - -app(MoonShine::class)->menu([ - MenuItem::make('Admins', new MoonShineUserResource()), -]); - - - - The fullWidth field method is outdated and will be removed - - - - To create a display grid in a form, you should use the Grid/Column decorations - - - - Laravel filemanager is excluded from the base package, it should be installed separately - - diff --git a/resources/views/pages/ru/decorations/block.blade.php b/resources/views/pages/ru/components/block.blade.php similarity index 100% rename from resources/views/pages/ru/decorations/block.blade.php rename to resources/views/pages/ru/components/block.blade.php diff --git a/resources/views/pages/ru/decorations/button.blade.php b/resources/views/pages/ru/components/button.blade.php similarity index 100% rename from resources/views/pages/ru/decorations/button.blade.php rename to resources/views/pages/ru/components/button.blade.php diff --git a/resources/views/pages/ru/components/collapse.blade.php b/resources/views/pages/ru/components/collapse.blade.php index f67800ee..c1a8470f 100644 --- a/resources/views/pages/ru/components/collapse.blade.php +++ b/resources/views/pages/ru/components/collapse.blade.php @@ -1,58 +1,38 @@ - - -Основы - - - Компонент moonshine::collapse позволяет сворачивать контент. - - - - - - - - @include("examples/components/collapse") - - - - -Отобразить развернутым + - Если параметр show имеет значение TRUE, - то по умолчанию блок будет отображаться развернутым. + Декоратор Collapse позволяет сворачивать fields и blocks с сохранением состояния. - - - - - - @include("examples/components/collapse-show") - - - - -Сохранение состояния - - - Если параметр persist имеет значение TRUE, то будет сохраняться состояние блока. - - - - - - - - @include("examples/components/collapse-persist") - - - + +use MoonShine\Decorations\Collapse; // [tl! focus] +use MoonShine\Decorations\Block; + +//... +public function fields(): array +{ + return [ + Block::make([ + Collapse::make('Title/Slug', [ // [tl! focus] + Text::make('Title') + ->fieldContainer(false), + + Text::make('Slug') + ->fieldContainer(false), + ]) // [tl! focus] + ->show() // отобразить развернутым (дополнительная опция) [tl! focus] + ]); + ]; +} +//... + + + + diff --git a/resources/views/pages/ru/decorations/tabs.blade.php b/resources/views/pages/ru/components/decoration_tabs.blade.php similarity index 71% rename from resources/views/pages/ru/decorations/tabs.blade.php rename to resources/views/pages/ru/components/decoration_tabs.blade.php index 83dad1bd..7f24b6ee 100644 --- a/resources/views/pages/ru/decorations/tabs.blade.php +++ b/resources/views/pages/ru/components/decoration_tabs.blade.php @@ -1,12 +1,17 @@ [ + ['url' => '#make', 'label' => 'Make'], + ['url' => '#active-tab', 'label' => 'Активная вкладка'], + ] ]" > +Make + - На форму для удобства можно добавить вкладки и сгруппировать поля. + Компонент Tabs позволяет создавать вкладки. diff --git a/resources/views/pages/ru/components/divider.blade.php b/resources/views/pages/ru/components/divider.blade.php index 3698f838..d6713788 100644 --- a/resources/views/pages/ru/components/divider.blade.php +++ b/resources/views/pages/ru/components/divider.blade.php @@ -1,54 +1,82 @@ - + Основы - Компонент moonshine::divider позволяет создать стилизованный разделитель контента. + Для разделения на зоны можно воспользоваться декорацией Divider. - + +use MoonShine\Decorations\Divider; - - - - @include("examples/components/divider") - - - +//... +public function fields(): array +{ + return [ + //... + Divider::make(), // [tl! focus] + //... + ]; +} +//... + -Текстовый разделитель + + + +Label - В качестве разделителя можно использовать текст. Для этого необходимо указать текст в параметре label. + В качестве разделителя можно использовать текст, для этого его необходимо передать методу make() в качестве аргумента. - + +use MoonShine\Decorations\Divider; + +//... +public function fields(): array +{ + return [ + //... + Divider::make('Divider'), // [tl! focus] + //... + ]; +} +//... + - - - - @include("examples/components/divider-label") - - - + + - Параметр centered позволяет разместить текст по центру. + Метод centered() позволяет отцентрировать текст. - + +use MoonShine\Decorations\Divider; + +//... +public function fields(): array +{ + return [ + //... + Divider::make('Divider') + ->centered(), // [tl! focus] + //... + ]; +} +//... + - - - - @include("examples/components/divider-label-center") - - - + + diff --git a/resources/views/pages/ru/decorations/heading.blade.php b/resources/views/pages/ru/components/heading.blade.php similarity index 100% rename from resources/views/pages/ru/decorations/heading.blade.php rename to resources/views/pages/ru/components/heading.blade.php diff --git a/resources/views/pages/ru/components/index.blade.php b/resources/views/pages/ru/components/index.blade.php index a18687a3..3aae7092 100644 --- a/resources/views/pages/ru/components/index.blade.php +++ b/resources/views/pages/ru/components/index.blade.php @@ -1,19 +1,102 @@ - + + +Основы + + + Компоненты в MoonShine являются основой для построения интерфейса.
+ В админ-панели уже реализовано множество компонентов, которые можно разделить на несколько групп: + Layouts, Decorations и Metrics. +
+ + + Layouts - компоненты используются для создания основных блоков админ-панели: + Flash, Footer, Header, LayoutBlock, LayoutBuilder, Menu, Profile, Sidebar, TopBar. + + + + Decorations - компоненты используются для визуального оформления пользовательского интерфейса: + Block, Collapse, Divider, Flex, Fragment, Grid, Heading, LineBreak, Tabs, TextBlock. + + + + Metrics - компоненты используются для создания информационных блоков: + DonutChartMetric, + LineChartMetric, + ValueMetric. + + + + Админ-панель MoonShine не ограничивает вас в использовании других компонентов, + которые могут быть реализованы с использованием + Livewire, + а так же Blade + компоненты. + + +MoonshineComponent - Для создания интерфейса админ-панели MoonShine используется множество UI компонентов.
- Вы можете воспользоваться этими компонентами для построения своих шаблонов, - кастомных полей, фильтров, декораций или страниц.
- Использование компонентов ускоряет разработку и позволяет сохранить единую стилистику проекта. + В MoonShine реализована консольная команда для создания MoonshineComponent, + в котором уже реализованы основные методы для использования в админ панели.
+ +php artisan moonshine:component + + - Если вы планируете использовать компоненты за пределами админ-панели, - то необходимо ваш шаблон добавить директиву с ассетами MoonShine. + В результате будет создан класс NameComponent, который является основой нового компонента.
+ Располагается он, по умолчанию, в директории app/MoonShine/Components.
+ А так же Blade файл для компонента в директории resources/views/admin/components.
- - @@moonShineAssets + + + + Метод make() предназначен для создания экземпляра компонента. + + + +use App\MoonShine\Components\NameComponent; // [tl! focus] + +//... + +public function components(): array +{ + return [ + NameComponent::make() // [tl! focus] + ]; +} + +//... + + + + Метод viewData() позволяет передать данные в шаблон компонента. + + + +namespace App\MoonShine\Components; // [tl! focus] + +//... + +final class Test extends MoonshineComponent +{ + protected function viewData(): array + { + return []; + } +} + +//...
diff --git a/resources/views/pages/ru/decorations/layout.blade.php b/resources/views/pages/ru/components/layout.blade.php similarity index 100% rename from resources/views/pages/ru/decorations/layout.blade.php rename to resources/views/pages/ru/components/layout.blade.php diff --git a/resources/views/pages/ru/components/metric_donut_chart.blade.php b/resources/views/pages/ru/components/metric_donut_chart.blade.php new file mode 100644 index 00000000..66520e27 --- /dev/null +++ b/resources/views/pages/ru/components/metric_donut_chart.blade.php @@ -0,0 +1,56 @@ + + +Make + + + Метрика DonutChartMetric предназначена для создания Donut графиков. + + + + Создать DonutChartMetric можно воспользовавшись статическим методом make(). + + + +make(Closure|string $label) + + + + Метод values() позволяет указать значение для метрики. + + + +values(array|Closure $values) + + + +use MoonShine\Metrics\DonutChartMetric; // [tl! focus] + +//... + +public function components(): array +{ + return [ + DonutChartMetric::make('Subscribers') // [tl! focus] + ->values(['CutCode' => 10000, 'Apple' => 9999]) // [tl! focus] + ]; +} + +//... + + + + + +Ширина блока + +@include('pages.ru.components.shared.metric_column_span', ['metric' => 'DonutChartMetric']) + + diff --git a/resources/views/pages/ru/components/metric_line_chart.blade.php b/resources/views/pages/ru/components/metric_line_chart.blade.php new file mode 100644 index 00000000..458090ad --- /dev/null +++ b/resources/views/pages/ru/components/metric_line_chart.blade.php @@ -0,0 +1,131 @@ + + +Make + + + Метрика LineChartMetric предназначена для отображения линейных графиков. + + + + Создать LineChartMetric можно воспользовавшись статическим методом make(). + + + +make(Closure|string $label) + + + + Метод line() позволяет добавить линию значений в метрику. + В ValueMetric можно добавить несколько линий. + + + +line( + array|Closure $line, + string|array|Closure $color = '#7843E9' +) + + + + $line - значения для построения графика,
+ $color - цвет линии. +
+ + +use MoonShine\Metrics\LineChartMetric; // [tl! focus] + +//... + +public function components(): array +{ + return [ + LineChartMetric::make('Orders') // [tl! focus:start] + ->line([ + 'Profit' => Order::query() + ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') + ->groupBy('date') + ->pluck('sum','date') + ->toArray() + ]) + ->line([ + 'Avg' => Order::query() + ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') + ->groupBy('date') + ->pluck('avg','date') + ->toArray() + ], '#EC4176') // [tl! focus:end] + ]; +} + +//... + + + + Можно задать несколько линий через один метод line. + + + +use MoonShine\Metrics\LineChartMetric; // [tl! focus] + +//... + +public function components(): array +{ + return [ + LineChartMetric::make('Orders') // [tl! focus:start] + ->line([ + 'Profit' => Order::query() + ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') + ->groupBy('date') + ->pluck('sum','date') + ->toArray(), + 'Avg' => Order::query() + ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') + ->groupBy('date') + ->pluck('avg','date') + ->toArray() + ],[ + 'red', 'blue' + ]) // [tl! focus:end] + ]; +} + +//... + + + + + +Сортировка ключей + + + По умолчанию у графика LineChart ключи сортируются по возрастанию. + Эту особенность можно отключить, используя метод withoutSortKeys(). + + + +LineChartMetric::make('Orders') + ->line([ + 'Profit' => Order::query() + ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') + ->groupBy('date') + ->pluck('sum','date') + ->toArray() + ]) + ->withoutSortKeys(), // [tl! focus] + + +Ширина блока + +@include('pages.ru.components.shared.metric_column_span', ['metric' => 'LineChartMetric']) + +
diff --git a/resources/views/pages/ru/components/metric_value.blade.php b/resources/views/pages/ru/components/metric_value.blade.php new file mode 100644 index 00000000..4956a5e4 --- /dev/null +++ b/resources/views/pages/ru/components/metric_value.blade.php @@ -0,0 +1,129 @@ + + +Make + + + Метрика ValueMetric предназначена для отображения какого-либо значения. + Например, сколько всего записей в таблице. + + + + Создать ValueMetric можно воспользовавшись статическим методом make(). + + + +make(Closure|string $label) + + + + Метод value() позволяет указать значение для метрики. + + + +value(int|string|float|Closure $value) + + + +use MoonShine\Metrics\ValueMetric; // [tl! focus] + +//... + +public function components(): array +{ + return [ + ValueMetric::make('Completed orders') + ->value(Order::completed()->count()) // [tl! focus:-1] + ]; +} + +//... + + + + + +Прогресс + + + Метод progress() позволяет отобразить индикатор прогресса достижения цели в метрике. + + + +progress(int|float|Closure $target) + + + +use MoonShine\Metrics\ValueMetric; + +//... + +public function components(): array +{ + return [ + ValueMetric::make('Open tasks') + ->value(Task::opened()->count()) + ->progress(Task::count()) // [tl! focus] + ]; +} + +//... + + + + При использовании индикатора прогресса, методу value() необходимо передать числовое значение + или замыкание, которое вернет число. + + + + + +Формат значения + + + Метод valueFormat() позволяет отформатировать значение метрики и добавить префикс и суффикс. + + + +valueFormat(string|Closure $value) + + + +use MoonShine\Metrics\ValueMetric; + +//... + +public function components(): array +{ + return [ + ValueMetric::make('Profit') + ->value(Order::completed()->sum('price')) + ->valueFormat('Today ${value}') // [tl! focus:-1] + ]; +} + +//... + + + + + +Icon + +@include('pages.ru.components.shared.metric_icon', ['metric' => 'ValueMetric']) + +Ширина блока + +@include('pages.ru.components.shared.metric_column_span', ['metric' => 'ValueMetric']) + + diff --git a/resources/views/pages/ru/components/shared/metric_column_span.blade.php b/resources/views/pages/ru/components/shared/metric_column_span.blade.php new file mode 100644 index 00000000..60b5d610 --- /dev/null +++ b/resources/views/pages/ru/components/shared/metric_column_span.blade.php @@ -0,0 +1,81 @@ + + Метод columnSpan() позволяет задать ширину блока в Grid сетке. + + + +columnSpan( + int $columnSpan, + int $adaptiveColumnSpan = 12 +) + + + +use App\Models\Article; +use MoonShine\Decorations\Grid; +use MoonShine\Metrics\{{ $metric }}; + +//... + +public function components(): array +{ + return [ + Grid::make([ // [tl! focus] + {{ $metric }}::make({{ $metric === 'DonutChartMetric' ? 'Subscribers' : 'Articles' }}) +@if( $metric === 'ValueMetric') + ->value(Article::count()) +@elseif( $metric === 'DonutChartMetric') + ->values(['CutCode' => 10000, 'Apple' => 9999]) +@elseif( $metric === 'LineChartMetric') + ->line([ + 'Count' => [ + now()->subDays()->format('Y-m-d') => + Article::whereDate( + 'created_at', + now()->subDays()->format('Y-m-d') + )->count(), + now()->format('Y-m-d') => + Article::whereDate( + 'created_at', + now()->subDays()->format('Y-m-d') + )->count() + ] + ]) +@endif + ->columnSpan(6), // [tl! focus] + {{ $metric }}::make( {{ $metric === 'DonutChartMetric' ? 'Tasks' : 'Comments' }}) +@if( $metric === 'ValueMetric') + ->value(Comment::count()) +@elseif( $metric === 'DonutChartMetric') + ->values(['New' => 234, 'Done' => 421]) +@elseif( $metric === 'LineChartMetric') + ->line([ + 'Count' => [ + now()->subDays()->format('Y-m-d') => + Comment::whereDate( + 'created_at', + now()->subDays()->format('Y-m-d') + )->count(), + now()->format('Y-m-d') => + Comment::whereDate( + 'created_at', + now()->subDays()->format('Y-m-d') + )->count() + ] + ]) +@endif + ->columnSpan(6) // [tl! focus] + ]) // [tl! focus] + ]; +} + +//... + + + + За более подробной информацией обратитесь к разделу + Декорация Layout. + + + + + diff --git a/resources/views/pages/ru/components/shared/metric_icon.blade.php b/resources/views/pages/ru/components/shared/metric_icon.blade.php new file mode 100644 index 00000000..a800f4ff --- /dev/null +++ b/resources/views/pages/ru/components/shared/metric_icon.blade.php @@ -0,0 +1,29 @@ + + Метод icon() позволяет добавить иконку к метрике. + + + +use MoonShine\Metrics\ValueMetric; + +//... + +public function components(): array +{ + return [ + ValueMetric::make('Orders') + ->value(Order::count()) + ->icon('heroicons.shopping-bag') // [tl! focus] + ]; +} + +//... + + + + За более подробной информацией обратитесь к разделу + Icons. + + + + + diff --git a/resources/views/pages/ru/configuration.blade.php b/resources/views/pages/ru/configuration.blade.php index e6428cca..4470a83e 100644 --- a/resources/views/pages/ru/configuration.blade.php +++ b/resources/views/pages/ru/configuration.blade.php @@ -57,7 +57,7 @@ 'disk' => 'public', // [tl! focus] 'forms' => [ // [tl! focus] - # форма аунтификации + # форма аутентификации 'login' => LoginForm::class // [tl! focus] ], // [tl! focus] diff --git a/resources/views/pages/ru/decorations/collapse.blade.php b/resources/views/pages/ru/decorations/collapse.blade.php deleted file mode 100644 index c1a8470f..00000000 --- a/resources/views/pages/ru/decorations/collapse.blade.php +++ /dev/null @@ -1,38 +0,0 @@ - - - - Декоратор Collapse позволяет сворачивать fields и blocks с сохранением состояния. - - - -use MoonShine\Decorations\Collapse; // [tl! focus] -use MoonShine\Decorations\Block; - -//... -public function fields(): array -{ - return [ - Block::make([ - Collapse::make('Title/Slug', [ // [tl! focus] - Text::make('Title') - ->fieldContainer(false), - - Text::make('Slug') - ->fieldContainer(false), - ]) // [tl! focus] - ->show() // отобразить развернутым (дополнительная опция) [tl! focus] - ]); - ]; -} -//... - - - - - - diff --git a/resources/views/pages/ru/decorations/divider.blade.php b/resources/views/pages/ru/decorations/divider.blade.php deleted file mode 100644 index d6713788..00000000 --- a/resources/views/pages/ru/decorations/divider.blade.php +++ /dev/null @@ -1,82 +0,0 @@ - - -Основы - - - Для разделения на зоны можно воспользоваться декорацией Divider. - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make(), // [tl! focus] - //... - ]; -} -//... - - - - - -Label - - - В качестве разделителя можно использовать текст, для этого его необходимо передать методу make() в качестве аргумента. - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make('Divider'), // [tl! focus] - //... - ]; -} -//... - - - - - - - Метод centered() позволяет отцентрировать текст. - - - -use MoonShine\Decorations\Divider; - -//... -public function fields(): array -{ - return [ - //... - Divider::make('Divider') - ->centered(), // [tl! focus] - //... - ]; -} -//... - - - - - - diff --git a/resources/views/pages/ru/decorations/index.blade.php b/resources/views/pages/ru/decorations/index.blade.php deleted file mode 100644 index 0bc2b4c7..00000000 --- a/resources/views/pages/ru/decorations/index.blade.php +++ /dev/null @@ -1,15 +0,0 @@ - - - Декорации задаются в методах ресурса fields или filters. - - - - Служат для улучшения внешнего вида полей и повышения качества интерфейса. - - - diff --git a/resources/views/pages/ru/fields/enum.blade.php b/resources/views/pages/ru/fields/enum.blade.php index 1f2e3cb3..ddaf3ca8 100644 --- a/resources/views/pages/ru/fields/enum.blade.php +++ b/resources/views/pages/ru/fields/enum.blade.php @@ -74,7 +74,7 @@ public function toString(): ?string то в preview поле отобразиться в виде значка определенного цвета. -@include('pages.ru.components.shared.colors') +@include('pages.ru.ui.shared.colors') namespace App\Enums; diff --git a/resources/views/pages/ru/fields/index.blade.php b/resources/views/pages/ru/fields/index.blade.php index 9d4b4e2c..9346735e 100644 --- a/resources/views/pages/ru/fields/index.blade.php +++ b/resources/views/pages/ru/fields/index.blade.php @@ -320,7 +320,7 @@ public function fields(): array badge(string|Closure|null $color = null) -@include('pages.ru.components.shared.colors') +@include('pages.ru.ui.shared.colors') //... diff --git a/resources/views/pages/ru/menu.blade.php b/resources/views/pages/ru/menu.blade.php index 49cdf273..7287a249 100644 --- a/resources/views/pages/ru/menu.blade.php +++ b/resources/views/pages/ru/menu.blade.php @@ -264,7 +264,7 @@ protected function menu(): array Иконка - У пункта меню и у группы можно задать иконку. Это можно реализовать несколькоми методами. + У пункта меню и у группы можно задать иконку. Это можно реализовать несколькими методами. diff --git a/resources/views/pages/ru/metrics/donut_chart.blade.php b/resources/views/pages/ru/metrics/donut_chart.blade.php deleted file mode 100644 index b22efe89..00000000 --- a/resources/views/pages/ru/metrics/donut_chart.blade.php +++ /dev/null @@ -1,31 +0,0 @@ - - - - Позволяет создавать Donut график для метрик. - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\DonutChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - DonutChartMetric::make('Подписчики') - ->values(['CutCode' => 10000, 'Apple' => 9999]), - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/ru/metrics/index.blade.php b/resources/views/pages/ru/metrics/index.blade.php deleted file mode 100644 index c1c25d89..00000000 --- a/resources/views/pages/ru/metrics/index.blade.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - Блоки для отображения статистики. - - - - Можно вывести на главной странице панели управления - и в каждом отдельном ресурсе. - - - - Метрикам также доступны методы декораций - Layout (columnSpan). - - diff --git a/resources/views/pages/ru/metrics/line_chart.blade.php b/resources/views/pages/ru/metrics/line_chart.blade.php deleted file mode 100644 index ccbbe738..00000000 --- a/resources/views/pages/ru/metrics/line_chart.blade.php +++ /dev/null @@ -1,99 +0,0 @@ - - - - Позволяет создавать линейный график для метрик. - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\LineChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray() - ]) - ->line([ - 'Avg' => Order::query() - ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('avg','date') - ->toArray() - ], '#EC4176'), - ]; - } // [tl! focus:end] - - //... -} - - - - или используя один метод line: - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\LineChartMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray(), - 'Avg' => Order::query() - ->selectRaw('AVG(price) as avg, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('avg','date') - ->toArray() - ],[ - 'red', 'blue' - ]) - ]; - } // [tl! focus:end] - - //... -} - - - - - - - По умолчанию у графика LineChart ключи сортируются по возрастанию. - Эту особенность можно отключить, используя метод withoutSortKeys(). - - - -LineChartMetric::make('Orders') - ->line([ - 'Profit' => Order::query() - ->selectRaw('SUM(price) as sum, DATE_FORMAT(created_at, "%d.%m.%Y") as date') - ->groupBy('date') - ->pluck('sum','date') - ->toArray() - ]) - ->withoutSortKeys(), // [tl! focus] - - - diff --git a/resources/views/pages/ru/metrics/value.blade.php b/resources/views/pages/ru/metrics/value.blade.php deleted file mode 100644 index eed90e43..00000000 --- a/resources/views/pages/ru/metrics/value.blade.php +++ /dev/null @@ -1,89 +0,0 @@ - - - - Предназначено для отображения простого значения. Например, сколько всего в таблице определенных записей. - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Завершенных заказов') - ->value(Orders::completed()->count()) - ]; - } // [tl! focus:end] - - //... -} - - - - - - - Также есть возможность отображения в виде прогресса достижения цели. - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Open tasks') - ->value(Task::opened()->count()) - ->progress(200) // Конечная цель - ]; - } // [tl! focus:end] - - //... -} - - - - - - -Выводимое значение можно отформатировать и добавить префикс и суффикс. - - - -namespace MoonShine\Resources; - -use MoonShine\Metrics\ValueMetric; - -class PostResource extends Resource -{ - //... - - public function metrics(): array // [tl! focus:start] - { - return [ - ValueMetric::make('Profit') - ->value(Orders::completed()->sum('price')) - ->valueFormat('Today ${value}') - ]; - } // [tl! focus:end] - - //... -} - - - - - - diff --git a/resources/views/pages/ru/components/alert.blade.php b/resources/views/pages/ru/ui/alert.blade.php similarity index 98% rename from resources/views/pages/ru/components/alert.blade.php rename to resources/views/pages/ru/ui/alert.blade.php index 01e16ef4..f9359642 100644 --- a/resources/views/pages/ru/components/alert.blade.php +++ b/resources/views/pages/ru/ui/alert.blade.php @@ -24,7 +24,7 @@ Изменить тип уведомления можно указав у компонента type. -@include('pages.ru.components.shared.type') +@include('pages.ru.ui.shared.type') diff --git a/resources/views/pages/ru/components/badge.blade.php b/resources/views/pages/ru/ui/badge.blade.php similarity index 100% rename from resources/views/pages/ru/components/badge.blade.php rename to resources/views/pages/ru/ui/badge.blade.php diff --git a/resources/views/pages/ru/components/boolean.blade.php b/resources/views/pages/ru/ui/boolean.blade.php similarity index 100% rename from resources/views/pages/ru/components/boolean.blade.php rename to resources/views/pages/ru/ui/boolean.blade.php diff --git a/resources/views/pages/ru/components/box.blade.php b/resources/views/pages/ru/ui/box.blade.php similarity index 100% rename from resources/views/pages/ru/components/box.blade.php rename to resources/views/pages/ru/ui/box.blade.php diff --git a/resources/views/pages/ru/components/breadcrumbs.blade.php b/resources/views/pages/ru/ui/breadcrumbs.blade.php similarity index 100% rename from resources/views/pages/ru/components/breadcrumbs.blade.php rename to resources/views/pages/ru/ui/breadcrumbs.blade.php diff --git a/resources/views/pages/ru/components/card.blade.php b/resources/views/pages/ru/ui/card.blade.php similarity index 100% rename from resources/views/pages/ru/components/card.blade.php rename to resources/views/pages/ru/ui/card.blade.php diff --git a/resources/views/pages/en/components/collapse.blade.php b/resources/views/pages/ru/ui/collapse.blade.php similarity index 54% rename from resources/views/pages/en/components/collapse.blade.php rename to resources/views/pages/ru/ui/collapse.blade.php index 64ef72f8..f67800ee 100644 --- a/resources/views/pages/en/components/collapse.blade.php +++ b/resources/views/pages/ru/ui/collapse.blade.php @@ -1,15 +1,15 @@ -Basics +Основы - The moonshine::collapse component allows you to collapse content + Компонент moonshine::collapse позволяет сворачивать контент. @@ -22,10 +22,11 @@ -Show expanded +Отобразить развернутым - If the show parameter is set to TRUE, then by default the block will be displayed expanded + Если параметр show имеет значение TRUE, + то по умолчанию блок будет отображаться развернутым. @@ -38,10 +39,10 @@ -Save state +Сохранение состояния - If the persist parameter is set to TRUE, then the state of the block will be saved + Если параметр persist имеет значение TRUE, то будет сохраняться состояние блока. diff --git a/resources/views/pages/en/components/divider.blade.php b/resources/views/pages/ru/ui/divider.blade.php similarity index 59% rename from resources/views/pages/en/components/divider.blade.php rename to resources/views/pages/ru/ui/divider.blade.php index df427e91..3698f838 100644 --- a/resources/views/pages/en/components/divider.blade.php +++ b/resources/views/pages/ru/ui/divider.blade.php @@ -1,14 +1,14 @@ -Basics +Основы - The moonshine::divider component allows you to create a stylized content divider + Компонент moonshine::divider позволяет создать стилизованный разделитель контента. @@ -21,10 +21,10 @@ -Text divider +Текстовый разделитель - You can use text as a separator, for this you need to specify the text in the label parameter + В качестве разделителя можно использовать текст. Для этого необходимо указать текст в параметре label. @@ -38,7 +38,7 @@ - The centered parameter allows you to center the text + Параметр centered позволяет разместить текст по центру. diff --git a/resources/views/pages/ru/components/dropdown.blade.php b/resources/views/pages/ru/ui/dropdown.blade.php similarity index 97% rename from resources/views/pages/ru/components/dropdown.blade.php rename to resources/views/pages/ru/ui/dropdown.blade.php index 3b5d94ba..c40b8930 100644 --- a/resources/views/pages/ru/components/dropdown.blade.php +++ b/resources/views/pages/ru/ui/dropdown.blade.php @@ -30,7 +30,7 @@ Расположение -@include('pages.ru.components.shared.placement') +@include('pages.ru.ui.shared.placement') diff --git a/resources/views/pages/ru/components/files.blade.php b/resources/views/pages/ru/ui/files.blade.php similarity index 100% rename from resources/views/pages/ru/components/files.blade.php rename to resources/views/pages/ru/ui/files.blade.php diff --git a/resources/views/pages/ru/components/form.blade.php b/resources/views/pages/ru/ui/form.blade.php similarity index 100% rename from resources/views/pages/ru/components/form.blade.php rename to resources/views/pages/ru/ui/form.blade.php diff --git a/resources/views/pages/ru/components/grid.blade.php b/resources/views/pages/ru/ui/grid.blade.php similarity index 100% rename from resources/views/pages/ru/components/grid.blade.php rename to resources/views/pages/ru/ui/grid.blade.php diff --git a/resources/views/pages/ru/components/icon.blade.php b/resources/views/pages/ru/ui/icon.blade.php similarity index 100% rename from resources/views/pages/ru/components/icon.blade.php rename to resources/views/pages/ru/ui/icon.blade.php diff --git a/resources/views/pages/ru/ui/index.blade.php b/resources/views/pages/ru/ui/index.blade.php new file mode 100644 index 00000000..a18687a3 --- /dev/null +++ b/resources/views/pages/ru/ui/index.blade.php @@ -0,0 +1,19 @@ + + + + Для создания интерфейса админ-панели MoonShine используется множество UI компонентов.
+ Вы можете воспользоваться этими компонентами для построения своих шаблонов, + кастомных полей, фильтров, декораций или страниц.
+ Использование компонентов ускоряет разработку и позволяет сохранить единую стилистику проекта. +
+ + + Если вы планируете использовать компоненты за пределами админ-панели, + то необходимо ваш шаблон добавить директиву с ассетами MoonShine. + + + + @@moonShineAssets + + +
diff --git a/resources/views/pages/ru/components/link.blade.php b/resources/views/pages/ru/ui/link.blade.php similarity index 100% rename from resources/views/pages/ru/components/link.blade.php rename to resources/views/pages/ru/ui/link.blade.php diff --git a/resources/views/pages/ru/components/loader.blade.php b/resources/views/pages/ru/ui/loader.blade.php similarity index 100% rename from resources/views/pages/ru/components/loader.blade.php rename to resources/views/pages/ru/ui/loader.blade.php diff --git a/resources/views/pages/ru/components/modal.blade.php b/resources/views/pages/ru/ui/modal.blade.php similarity index 100% rename from resources/views/pages/ru/components/modal.blade.php rename to resources/views/pages/ru/ui/modal.blade.php diff --git a/resources/views/pages/ru/components/offcanvas.blade.php b/resources/views/pages/ru/ui/offcanvas.blade.php similarity index 100% rename from resources/views/pages/ru/components/offcanvas.blade.php rename to resources/views/pages/ru/ui/offcanvas.blade.php diff --git a/resources/views/pages/ru/components/paginations.blade.php b/resources/views/pages/ru/ui/paginations.blade.php similarity index 100% rename from resources/views/pages/ru/components/paginations.blade.php rename to resources/views/pages/ru/ui/paginations.blade.php diff --git a/resources/views/pages/ru/components/popover.blade.php b/resources/views/pages/ru/ui/popover.blade.php similarity index 96% rename from resources/views/pages/ru/components/popover.blade.php rename to resources/views/pages/ru/ui/popover.blade.php index 2fc247a4..b9edec0f 100644 --- a/resources/views/pages/ru/components/popover.blade.php +++ b/resources/views/pages/ru/ui/popover.blade.php @@ -10,7 +10,7 @@ C помощью компонента moonshine::popover можно создать всплывающее окно. -@include('pages.ru.components.shared.placement') +@include('pages.ru.ui.shared.placement') diff --git a/resources/views/pages/ru/components/progress_bar.blade.php b/resources/views/pages/ru/ui/progress_bar.blade.php similarity index 93% rename from resources/views/pages/ru/components/progress_bar.blade.php rename to resources/views/pages/ru/ui/progress_bar.blade.php index 514a5e60..f631d55e 100644 --- a/resources/views/pages/ru/components/progress_bar.blade.php +++ b/resources/views/pages/ru/ui/progress_bar.blade.php @@ -11,7 +11,7 @@ Компонент moonshine::progress-bar позволяет создавать индикатор прогресса. -@include('pages.ru.components.shared.themes-colors') +@include('pages.ru.ui.shared.themes-colors') @@ -29,7 +29,7 @@ Для создания радиального индикатора прогресса необходимо компоненту передать параметр radial со значением TRUE. -@include('pages.ru.components.shared.sizes') +@include('pages.ru.ui.shared.sizes') diff --git a/resources/views/pages/ru/components/rating.blade.php b/resources/views/pages/ru/ui/rating.blade.php similarity index 100% rename from resources/views/pages/ru/components/rating.blade.php rename to resources/views/pages/ru/ui/rating.blade.php diff --git a/resources/views/pages/ru/components/shared/colors.blade.php b/resources/views/pages/ru/ui/shared/colors.blade.php similarity index 100% rename from resources/views/pages/ru/components/shared/colors.blade.php rename to resources/views/pages/ru/ui/shared/colors.blade.php diff --git a/resources/views/pages/ru/components/shared/placement.blade.php b/resources/views/pages/ru/ui/shared/placement.blade.php similarity index 100% rename from resources/views/pages/ru/components/shared/placement.blade.php rename to resources/views/pages/ru/ui/shared/placement.blade.php diff --git a/resources/views/pages/ru/components/shared/sizes.blade.php b/resources/views/pages/ru/ui/shared/sizes.blade.php similarity index 100% rename from resources/views/pages/ru/components/shared/sizes.blade.php rename to resources/views/pages/ru/ui/shared/sizes.blade.php diff --git a/resources/views/pages/ru/components/shared/themes-colors.blade.php b/resources/views/pages/ru/ui/shared/themes-colors.blade.php similarity index 100% rename from resources/views/pages/ru/components/shared/themes-colors.blade.php rename to resources/views/pages/ru/ui/shared/themes-colors.blade.php diff --git a/resources/views/pages/ru/components/shared/type.blade.php b/resources/views/pages/ru/ui/shared/type.blade.php similarity index 100% rename from resources/views/pages/ru/components/shared/type.blade.php rename to resources/views/pages/ru/ui/shared/type.blade.php diff --git a/resources/views/pages/ru/components/spinner.blade.php b/resources/views/pages/ru/ui/spinner.blade.php similarity index 95% rename from resources/views/pages/ru/components/spinner.blade.php rename to resources/views/pages/ru/ui/spinner.blade.php index 90a2f550..eb2956a4 100644 --- a/resources/views/pages/ru/components/spinner.blade.php +++ b/resources/views/pages/ru/ui/spinner.blade.php @@ -24,7 +24,7 @@ Размер -@include('pages.ru.components.shared.sizes') +@include('pages.ru.ui.shared.sizes') @@ -38,7 +38,7 @@ Цвет -@include('pages.ru.components.shared.themes-colors') +@include('pages.ru.ui.shared.themes-colors') diff --git a/resources/views/pages/ru/components/table.blade.php b/resources/views/pages/ru/ui/table.blade.php similarity index 100% rename from resources/views/pages/ru/components/table.blade.php rename to resources/views/pages/ru/ui/table.blade.php diff --git a/resources/views/pages/ru/components/tabs.blade.php b/resources/views/pages/ru/ui/tabs.blade.php similarity index 100% rename from resources/views/pages/ru/components/tabs.blade.php rename to resources/views/pages/ru/ui/tabs.blade.php diff --git a/resources/views/pages/ru/components/thumbnail.blade.php b/resources/views/pages/ru/ui/thumbnail.blade.php similarity index 100% rename from resources/views/pages/ru/components/thumbnail.blade.php rename to resources/views/pages/ru/ui/thumbnail.blade.php diff --git a/resources/views/pages/ru/components/title.blade.php b/resources/views/pages/ru/ui/title.blade.php similarity index 100% rename from resources/views/pages/ru/components/title.blade.php rename to resources/views/pages/ru/ui/title.blade.php diff --git a/resources/views/pages/ru/components/toast.blade.php b/resources/views/pages/ru/ui/toast.blade.php similarity index 96% rename from resources/views/pages/ru/components/toast.blade.php rename to resources/views/pages/ru/ui/toast.blade.php index f9b85b0b..a88c419d 100644 --- a/resources/views/pages/ru/components/toast.blade.php +++ b/resources/views/pages/ru/ui/toast.blade.php @@ -12,7 +12,7 @@ -@include('pages.ru.components.shared.type') +@include('pages.ru.ui.shared.type') diff --git a/resources/views/pages/ru/components/tooltip.blade.php b/resources/views/pages/ru/ui/tooltip.blade.php similarity index 96% rename from resources/views/pages/ru/components/tooltip.blade.php rename to resources/views/pages/ru/ui/tooltip.blade.php index 75ec3c5f..7a19b466 100644 --- a/resources/views/pages/ru/components/tooltip.blade.php +++ b/resources/views/pages/ru/ui/tooltip.blade.php @@ -11,7 +11,7 @@ C помощью компонента moonshine::tooltip можно создавать удобные подсказки. -@include('pages.ru.components.shared.placement') +@include('pages.ru.ui.shared.placement')