https://github.com/markwalet/nova-modal-response
A Laravel Nova asset for Modal responses on an action.
https://github.com/markwalet/nova-modal-response
Last synced: about 1 year ago
JSON representation
A Laravel Nova asset for Modal responses on an action.
- Host: GitHub
- URL: https://github.com/markwalet/nova-modal-response
- Owner: markwalet
- License: mit
- Created: 2023-01-27T15:59:36.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-02-03T10:46:06.000Z (over 1 year ago)
- Last Synced: 2025-03-11T10:03:17.904Z (about 1 year ago)
- Language: PHP
- Size: 873 KB
- Stars: 14
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# Nova Modal Response
[](LICENSE.md)
[](https://packagist.org/packages/markwalet/nova-modal-response)
[](https://packagist.org/packages/markwalet/nova-modal-response)
Enabling custom modals for action responses in [Laravel Nova](https://nova.laravel.com).

More info for this specific feature can be found in the [Nova Documentation](https://nova.laravel.com/docs/4.0/actions/defining-actions.html#custom-modal-responses).
## Installation
```shell
composer require markwalet/nova-modal-response
```
## Usage
```php
use Markwalet\NovaModalResponse\ModalResponse;
ModalResponse::text('This is way better than that small notification in the bottom right!')
->title('Result in a modal');
// Modals can also be manually created in Nova
use Laravel\Nova\Actions\Action;
return Action::modal('modal-response', [
'title' => 'Result in a model',
'body' => 'This is way better than that small notification in the bottom right!',
]);
```
When you want to render raw html, you can use the `html` parameter instead:
```php
ModalResponse::html('
- Show this package to your friends
- Contribute
- ???
- Profit!
```
There is also a special mode for rendering code snippets. This will surround the body with a `
` and `` tag but still leave escaping enabled.
```php
ModalResponse::code(file_get_contents(__FILE__))->title('Look at me!');
```
Syntax highlighting is enabled by default for code and json blocks. It is using [highlight.js](https://highlightjs.org/) under the hood. You can disable this by calling `->withoutSyntaxHighlighting()`.
If you want to show some serializable data to the client, you can do that as well:
```php
ModalResponse::json([
'lorem' => 'ipsum',
'dolor' => [
'sit',
'amet',
],
]);
```
You can also specify the size using the `size` option:
```php
ModalResponse::text('Hello world')->size('7xl');
```