This follow the lunar structure code.
First create folder call Pages and Components inside App\Http\Livewire it will become something like this.
App\Http\Livewire\Components
App\Http\Livewire\Pages
Moving on. we will create new Page call Foo
- Create livewire component call
FooIndexinsidePages
<?php
namespace App\Http\Livewire\Pages\Foo;
use Livewire\Component;
class FooIndex extends Component
{
public function render()
{
// in this example iam using default lunar layout.
// if you want to use your own layout it's up to you
return view('livewire.pages.foo.index')
->layout('adminhub::layouts.app');
}
}- Create livewire view call
index.blade.phpinresources/views/livewire/pages/foo/index.blade.php
<div>
This is from foo index
</div>- Add
fooroutes
Note: Pages only for routes.
Route::group([], function () {
Route::get('foo', \App\Http\Livewire\Pages\FooIndex::class)->name('hub.foo.index');
});
- Add custom menu inside
AppServiceProvider. refrence https://docs.lunarphp.io/extending/admin-hub.html#adding-to-menus
$slot = Menu::slot('sidebar');
$slot->addItem(function ($item) {
$item->name('Foo')->handle('hub.foo')
->route('hub.foo.index')
->icon('foo');
});First create FooIndex inside Pages
App\Http\Livewire\Pages\FooIndex
<?php
namespace App\Http\Livewire\Pages\FooIndex;
use Livewire\Component;
class FooIndex extends Component
{
public function render()
{
return view('livewire.pages.foo.index')
->layout('adminhub::layouts.app');
}
}
Inside resources/views/livewire/pages/foo/index.blade.php
<div>
@livewire('hub.components.settings.application.index')
</div>
Warning: for this to work, the route must be defined as follows in the routes>web.php file :
[EDIT] but thank you for sharing, it helps me a LOT! 🥇 [/EDIT]