PHP code example of moonshine / advanced
1. Go to this page and download the library: Download moonshine/advanced library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moonshine / advanced example snippets
use MoonShine\Advanced\Components\Stepper\Stepper;
use MoonShine\Advanced\Components\Stepper\Step;
Stepper::make([
Step::make([
Heading::make('Step 1 content')
], 'Step 1', 'Some description'),
Step::make([
FormBuilder::make()
], 'Step 2', 'Some description'),
Step::make([
// any components
], 'Step 3', 'Some description'),
])
Stepper::make([
Step::make(title: 'Step', description: 'Some description')->async('/html')
])
Stepper::make([
Step::make(title: 'Step', description: 'Some description')->async('/html', events: [
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'fragment-1')
])
])
Step::make(title: 'Step', description: 'Some description')
->whenChangingEvents([
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'fragment-2')
], once: false)
Step::make(title: 'Step', description: 'Some description')
->whenFinishEvents([
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'fragment-2')
], once: true)
Stepper::make([
// ...
], finishComponent: [
Heading::make('Thanks!')
]),
Stepper::make([
// ...
], nextText: 'Next step', finishText: 'Finish'),
Stepper::make([
// ...
])->changeNextButton(function(ActionButton $btn, int $index) {
return $btn->badge($index);
}),
Stepper::make([
// ...
])->current(2),
Stepper::make([
// ...
])->finished(),
Step::make()->nextLock(),
Stepper::make([
// ...
])->lock(),
Stepper::make([
// ...
])->lockWhenFinish(),
use MoonShine\Advanced\Components\AsyncTabs\AsyncTabs;
use MoonShine\Advanced\Components\AsyncTabs\AsyncTab;
AsyncTabs::make([
AsyncTab::make('Tab 1', '/html'),
AsyncTab::make('Tab 2', '/html')->icon('users'),
]),
use MoonShine\Advanced\Components\LinkGroup\LinkGroup;
use MoonShine\Advanced\Components\LinkGroup\LinkItem;
LinkGroup::make([
LinkItem::make('/documentation', 'Documentation', 'Some description')->icon('arrow-right'),
// ...
]),
use MoonShine\Advanced\Fields\RadioGroup;
RadioGroup::make('Sex')->options([
1 => 'Male',
2 => 'Female',
])->inline(),
use MoonShine\Advanced\Fields\CheckboxList;
CheckboxList::make('Plan')->options([
1 => 'Basic',
2 => 'Standard',
3 => 'Pro',
])->inline(),
use MoonShine\Advanced\Fields\ButtonGroup;
ButtonGroup::make('Plan')->options([
1 => 'Basic',
2 => 'Standard',
3 => 'Pro',
])->multiple(),
use MoonShine\MenuManager\MenuItem;
protected function menu(): array
{
return [
MenuItem::make('Users', UserResource::class)->spa(),
];
}
public function stepForm(MoonShineRequest $request): MoonShineJsonResponse
{
$request->validate([
'name' => ['ard'
]);
}
protected function components(): iterable
{
return [
Stepper::make([
Step::make([
FormBuilder::make()
->name('step_1_form')
->asyncMethod('stepForm')
->fields([
Grid::make([
Column::make([
Box::make([
Text::make('Name'),
Email::make('Email'),
RadioGroup::make('Sex')->options([
1 => 'Male',
2 => 'Female',
])->inline(),
])
])->columnSpan(6),
Column::make([
Box::make([
CheckboxList::make('Job title')->options([
1 => 'Developer',
2 => 'Team lead',
]),
ButtonGroup::make('Plan')->options([
1 => 'Free',
2 => 'Basic',
3 => 'Pro',
]),
])
])->columnSpan(6)
])
])
->hideSubmit()
], 'Step 1', 'Tell us about yourself')->nextLock()->whenChangingEvents([
AlpineJs::event(JsEvent::FORM_SUBMIT, 'step_1_form')
]),
Step::make([
AsyncTabs::make([
AsyncTab::make('How to use the project', '/html'),
AsyncTab::make('User agreement', '/html'),
]),
], 'Step 2', 'Rules')->icon('users'),
Step::make([], 'Step 3', 'Finishing')->async('/html', events: [
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'time')
])->whenFinishEvents([
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, 'time')
]),
], [
Heading::make('Thanks!'),
LinkGroup::make([
LinkItem::make('#', 'Link 1', 'Description 1')->icon('arrow-right'),
LinkItem::make('#', 'Link 2'),
])
], 'Next', 'Finish')->name('dashboard')->lock(),
Fragment::make([
time()
])->name('time'),
];
}