Overview
The admin hub is designed to be extended so you can add your own screens. You should develop your additional functionality using Laravel Livewire using the same approach as the core admin hub screens.Brand Customisation
You can now modify the hub logo and fav icon, please publish views using the command below.Staff Permissions
You can add additional permissions to authorise staff access. It will be shown in staff management screens for assign/revoke. Here is an example of how you would add a permission in ServiceProviderAfter adding new permissions, you must run
lunar:hub:permissions command to register into the hub.
The hub is using spatie/laravel-permission packageAdditional permissions are catogarised as third-party permissions. You should still implement authorisation checking respectively.Example:
middleware ‘can:permission-handle’
in-code Auth::user()->can(‘permission-handle’)Adding to Menus
Lunar uses dynamic menus in the UI which you can extend to add further links.Currently, only the side menu and settings menu are available to extend.
But we will be adding further menus into the core editing screens soon.
Adding a Link
Here is an example of how you would add a new link to the side menu.Adding a Section
A section allows you to group a collection of links. The section itself is a link. Here is an example of how you would add a new section to the side menu.Extending a Section
You can add new links to one of the existing menu sections.Menu authorization
You can also authorize the staff access using thegate method.
Adding an Icon
Lunar comes with a collection of icons you can use in the Resources folder. If you wish to supply your own, simply use an SVG instead, e.g.Slots
Slots allow you to add your own Livewire components to the screens around the hub. This is useful if you need to add extra forms or display certain data on pages like Product editing. Slots can be an extremely powerful addition to your store.Creating a Slot
A Slot is a Livewire component that implements theAbstractSlot interface.
Here’s a basic example of how this might look:
When creating a slot the namespace should contain either
Lunar or
Hub in order for the middleware to apply correctly.Available Methods
Aside from having all of Livewire’s methods available, there are some additional methods you need to define for things to run smoothly.getName
This is the name of the Livewire component and is referenced when rendering it
i.e.
hub in the
name to make sure the correct Middleware is applied without interfering with any
components you may already have for your Storefront.
The name should be the same as how you’ve registered the component with
Livewire:
getSlotHandle
This should be the unique handle for your Slot.
getSlotInitialValue
This method allows you to set any initial values on your slot before rendering.
getSlotPosition
Each page that supports slots will have different positions available where they
can be placed. Return the position you want it to appear here.
getSlotTitle
Return the title for the slot.
updateSlotModel
This is called when the parent component of your Slot is bound to changes. e.g.
if you have a slot on the product editing component, this will be called when
the product is saved.
handleSlotSave
Called before updateSlotModel so you can save any data you need to the
database.
render
Standard Livewire method to render the component view.
saveSlotData
This method allows you to store your data in the page and pass it to
handleSlotSave on save
Registering the Slot
Once you’ve created your Slot, you need to tell Lunar where it should go, you can do this in your ServiceProvider.Available Slots
Products
product.show
Rendered on the product editing screen
Positions
| Position | Description |
|---|---|
top | Displayed at the top of the product editing sections |
bottom | Displayed at the bottom of the product editing sections |
product.create
Rendered on the product creation screen
Positions
| Position | Description |
|---|---|
top | Displayed at the top of the product creation sections |
bottom | Displayed at the bottom of the product creation sections |
product.all
Rendered on the product creation screen
Positions
| Position | Description |
|---|---|
top | Displayed at the top of both the product creation and editing sections |
bottom | Displayed at the bottom of both the product creation and editing sections |
productvariant.show
Positions
| Position | Description |
|---|---|
top | Displayed at the top of both the product variant editing sections |
bottom | Displayed at the bottom of both the product variant editing sections |
Model View/Preview URLs
It can be useful to provide a link to a product in order for a store admin to see how it will live prior to it going live, or just to have a direct link to it. To enable this feature you will need to add a supporting class toconfig/lunar-hub/storefront.php.
Discounts
If you have registered your own discount types in the core, you will likely want to provide an interface so authenticated staff members can add the data required.You need to make sure you have registered your discount with the Lunar core beforehand.