LaravelPackages.net
Acme Inc.
Toggle sidebar
ianrothmann/inertia-laravel-app-service

RocketFramework Inertia Laravel Helpers

8.706
2
3.0
About ianrothmann/inertia-laravel-app-service

ianrothmann/inertia-laravel-app-service is a Laravel package for rocketframework inertia laravel helpers. It currently has 2 GitHub stars and 8.706 downloads on Packagist (latest version 3.0). Install it with composer require ianrothmann/inertia-laravel-app-service. Discover more Laravel packages by ianrothmann or browse all Laravel packages to compare alternatives.

Last updated

Rocket Inertia and Laravel App Framework Service

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 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

Docs coming soon

Star History Chart