Downloads
Stars
Version
RocketFramework for Inertia and Laravel.
composer install ianrothmann/inertia-laravel-app-service
In config/app.php (if it does not auto-configure)
Service provider
IanRothmann\InertiaApp\ServiceProviders\InertiaAppServiceProvider::class
Facades
'Rocket' =>IanRothmann\InertiaApp\Facades\InertiaApp::class
Publish the config
php artisan vendor:publish --provider="IanRothmann\InertiaApp\ServiceProviders\InertiaAppServiceProvider" --tag="config"
In the boot
method of AppServiceProvider.php
:
InertiaApp::register()->resolveMenuItemRightsWith(function($code){
//The code that is required to resolve a menu right
return Auth::check() && Auth::user()->hasRight($code);
});
Menus can be specified in middleware, but can also be modified in any controller before passing the view.
You can give the menu a name, for instance "main", and then chain the items. The icon is optional. If you need a custom item, you can use ->custom
$group=InertiaApp::menuGroup('Sub-menu','mdi-account')
->route('Page 1','pages.page1',[],'mdi-phone')
->link('Google','http://google.com','mdi-link');
InertiaApp::menu('main')
->route('Item 1','pages.spec',[1,2],'mdi-home')
->route('Item 2','pages.spec',[2,1],'mdi-phone','test')
->route('Item 3','pages.spec',[9,8],'mdi-phone')
->group($group)
->link('Google','http://google.com');
Sometimes one would like to prepend items (especially when modifying middleware defined menus from the controller. All item functions can start with prepend
to prepend.
$group=InertiaApp::menuGroup(Auth::user()->name,'mdi-account')
->route('Update profile','pages.user.profile',[],'mdi-account-card-details-outline')
->route('Change password','pages.user.changepassword',[],'mdi-key-variant');
InertiaApp::menu('main')
->prependGroup($group); //or prependRoute, prependCustom etc.
For brevity, we registered iview()
which is the same as Inertia::render()
.
You can also use page_title('Page title here',$addTobreadcrumbs=true)
to set the page title and breadcrumbs.
Docs coming soon
Docs coming soon