ianrothmann / inertia-laravel-app-service
RocketFramework Inertia Laravel Helpers
Installs: 3 505
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: >=7.4.0
- ianrothmann/tab-manager-laravel: ^1.0
- laravel/framework: >=8.0.0
- tightenco/ziggy: ^1.4
README
RocketFramework for Inertia and Laravel.
Installation
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"
Configuration
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
Menus can be specified in middleware, but can also be modified in any controller before passing the view.
Usage
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');
Prepending
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.
Helpers
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.
Front-end
Docs coming soon
Breadcrumbs
Docs coming soon