opscale-co / nova-package-tools
Tools for creating Nova packages
Requires
- php: ^8.2
- illuminate/contracts: ^9.28|^10.0|^11.0|^12.0
- spatie/laravel-package-tools: ^1.14
Requires (Dev)
- driftingly/rector-laravel: ^2.0
- larastan/larastan: ^3.6
- laravel/nova: ^5.7
- mockery/mockery: ^1.5
- opscale-co/strict-rules: ^1.1
- orchestra/testbench: ^7.7|^8.0|^9.0|^10.0
- phpunit/php-code-coverage: ^9.0|^10.0|^11.0
- phpunit/phpunit: ^9.5.24|^10.5|^11.5
- rector/rector: ^2.1
- tightenco/duster: ^3.2
README
At Opscale, we’re passionate about contributing to the open-source community by providing solutions that help businesses scale efficiently. If you’ve found our tools helpful, here are a few ways you can show your support:
⭐ Star this repository to help others discover our work and be part of our growing community. Every star makes a difference!
💬 Share your experience by leaving a review on Trustpilot or sharing your thoughts on social media. Your feedback helps us improve and grow!
📧 Send us feedback on what we can improve at feedback@opscale.co. We value your input to make our tools even better for everyone.
🙏 Get involved by actively contributing to our open-source repositories. Your participation benefits the entire community and helps push the boundaries of what’s possible.
💼 Hire us if you need custom dashboards, admin panels, internal tools or MVPs tailored to your business. With our expertise, we can help you systematize operations or enhance your existing product. Contact us at hire@opscale.co to discuss your project needs.
Thanks for helping Opscale continue to scale! 🚀
Description
This package extends Spatie's Laravel Package Tools to provide Nova-specific functionality for package development. It inherits all the features from the base package while adding support for Nova resources.
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require opscale-co/nova-package-tools
Usage
Getting Started
In your Nova package, you should let your service provider extend Opscale\NovaPackageTools\NovaPackageServiceProvider
:
use Opscale\NovaPackageTools\NovaPackageServiceProvider; use Spatie\LaravelPackageTools\Package; class YourNovaPackageServiceProvider extends NovaPackageServiceProvider { public function configurePackage(Package $package): void { $package ->name('your-nova-package') ->hasConfigFile() ->hasViews() ->hasMigration('create_your_package_tables') ->hasCommand(YourPackageCommand::class) // Nova-specific features are now directly available ->hasResource(YourResource::class) ->hasResources([ UserResource::class, PostResource::class, ]); } }
Nova Resources
The main addition this package provides is the ability to register Nova resources with your package.
Registering a Single Resource
You can register a single Nova resource using the hasResource
method:
use App\Nova\User; $package ->name('your-nova-package') ->hasResource(User::class);
Registering Multiple Resources
If your package provides multiple Nova resources, you can register them all at once using hasResources
:
use App\Nova\User; use App\Nova\Post; use App\Nova\Comment; $package ->name('your-nova-package') ->hasResources([ User::class, Post::class, Comment::class, ]);
You can also pass multiple resources as separate arguments:
$package ->name('your-nova-package') ->hasResources(User::class, Post::class, Comment::class);
Testing
npm run test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email development@opscale.co instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.